Nodes/TJ_PolkaDot/Colored Mask Compositor
ComfyUI Node

Colored Mask Compositor

Three masks, three colors, one node — the collage finishing step

By TJ16th·Created 11 months ago·Updated 11 months ago· 2
Colored Mask Compositor
  • base_image
  • mask_1
  • mask_2
  • mask_3
  • composite_image
color_1_r255
color_1_g0
color_1_b0
opacity_11.00
color_2_r0
color_2_g255
color_2_b0
opacity_21.00
color_3_r0
color_3_g0
color_3_b255
opacity_31.00
blend_modenormal

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_1 is required; leave mask_2 or mask_3 disconnected 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. normal for flat collage colors; multiply or add if 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 RGB error. 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_image isn't wired. Lower opacity_X or check the mask coverage.
CategoryTJ_PolkaDot

Inputs (17)

NameTypeDefaultDescription
base_imageIMAGEBase image to apply colored masks onto
mask_1MASKMask layer 1
color_1_rINT2550–255Red channel for mask 1
color_1_gINT00–255Green channel for mask 1
color_1_bINT00–255Blue channel for mask 1
opacity_1FLOAT1.000–1Opacity for mask 1 (0=transparent, 1=opaque)
color_2_rINT00–255Red channel for mask 2
color_2_gINT2550–255Green channel for mask 2
color_2_bINT00–255Blue channel for mask 2
opacity_2FLOAT1.000–1Opacity for mask 2 (0=transparent, 1=opaque)
color_3_rINT00–255Red channel for mask 3
color_3_gINT00–255Green channel for mask 3
color_3_bINT2550–255Blue channel for mask 3
opacity_3FLOAT1.000–1Opacity for mask 3 (0=transparent, 1=opaque)
blend_modeCOMBOnormalBlend mode for compositing masks
mask_2optMASKMask layer 2
mask_3optMASKMask layer 3

Outputs (1)

NameTypeDescription
composite_imageIMAGEFinal composited image