Colored Mask Compositor
Three masks, three colors, one node — the collage finishing step
- base_image
- mask_1
- mask_2
- mask_3
- composite_image
You've scattered a hundred hearts across a mask. They're white blobs on a black background - now you need color, and that's where collage workflows usually die, because giving every mask its own color means hand-wiring colorize nodes one at a time. Colored Mask Compositor (TJ_PolkaDot, TJ16th's three-node pack) composites up to three mask layers onto a base image, each with its own RGB color and opacity, in a single node. It's the last step of the polka-dot pipeline: generate stamps, place them, then color them.
How it works
For every mask you actually connect, the node builds a flat layer of your chosen color, sets alpha to mask × opacity, and blends it into the accumulating result using the selected blend mode. There are five modes - normal, multiply, screen, overlay, add - and the math is right out of a compositing textbook. Two details save you real grief:
- Masks auto-fit. If a mask doesn't match the base image's resolution, it gets bilinearly resized to match. This is what lets the pack's 1024×1024 ShapeMaskGenerator masks composite cleanly onto any resolution base without you touching a Resize node.
- Layers 2 and 3 are truly optional. Only
mask_1is required; leavemask_2ormask_3disconnected and their color/opacity fields just sit there ignored.
The inputs that matter
base_image(required) - the backdrop: a generated photo, a blank canvas, anything. Must be RGB.mask_1(required),mask_2,mask_3(optional) - your mask layers.color_X_r/color_X_g/color_X_b- RGB per layer, 0–255. Defaults are red, green, blue for layers 1–3.opacity_X- per-layer transparency, 0.0 to 1.0.blend_mode- one mode for the whole node.normalfor flat collage colors;multiplyoraddif you want the shapes to interact with what's underneath.
The single output is composite_image - wire it into Preview Image or Save Image, or keep it flowing through the graph.
The honest limits
Two things this node won't do, so you don't waste an evening discovering them. First, it's one flat color per mask, not per shape - if you want 30 individually-colored hearts, you need a separate mask per color and a chain of compositors, not one node. Second, one blend mode applies to all layers, and the output is plain RGB with no alpha channel, so if you're building transparent PNGs you'll be compositing this result onto your own alpha path.
Install
Standard custom-node install; deps are torch, numpy, pillow - nothing extra to pip, no models to fetch.
ComfyUI Manager → Custom Nodes Manager → search "TJ_PolkaDot" → Install → restart
# or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/TJ16th/ComfyUI-TJ-PolkaDot
# then restart ComfyUI
The pack uses ComfyUI's newer plugin API, so if the nodes don't show up after install, update ComfyUI before troubleshooting anything else.
Troubleshooting
Base image must be RGBerror. The code throws this when you feed it an RGBA or grayscale image. Convert to RGB first (a Convert Image node fixes it).- A layer's color does nothing. Check that the mask is actually connected - colors only apply to connected masks. Disconnected layers are skipped silently.
- Your image came out a solid color. The mask probably covers the whole frame at high opacity, or
base_imageisn't wired. Loweropacity_Xor check the mask coverage.
Inputs (17)
| Name | Type | Default | Description |
|---|---|---|---|
| base_image | IMAGE | Base image to apply colored masks onto | |
| mask_1 | MASK | Mask layer 1 | |
| color_1_r | INT | 2550–255 | Red channel for mask 1 |
| color_1_g | INT | 00–255 | Green channel for mask 1 |
| color_1_b | INT | 00–255 | Blue channel for mask 1 |
| opacity_1 | FLOAT | 1.000–1 | Opacity for mask 1 (0=transparent, 1=opaque) |
| color_2_r | INT | 00–255 | Red channel for mask 2 |
| color_2_g | INT | 2550–255 | Green channel for mask 2 |
| color_2_b | INT | 00–255 | Blue channel for mask 2 |
| opacity_2 | FLOAT | 1.000–1 | Opacity for mask 2 (0=transparent, 1=opaque) |
| color_3_r | INT | 00–255 | Red channel for mask 3 |
| color_3_g | INT | 00–255 | Green channel for mask 3 |
| color_3_b | INT | 2550–255 | Blue channel for mask 3 |
| opacity_3 | FLOAT | 1.000–1 | Opacity for mask 3 (0=transparent, 1=opaque) |
| blend_mode | COMBO | normal | Blend mode for compositing masks |
| mask_2opt | MASK | Mask layer 2 | |
| mask_3opt | MASK | Mask layer 3 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| composite_image | IMAGE | Final composited image |