Nodes/MachinePainting Nodes/πŸ‘Ύ Mask Composite Pro 2X
ComfyUI Node

πŸ‘Ύ Mask Composite Pro 2X

Two masks, one clean union

By machinepaintingΒ·Created 10 months agoΒ·Updated 4 months agoΒ· 9
πŸ‘Ύ Mask Composite Pro 2X
  • mask_1
  • mask_2
  • mask
β—„output_selectallβ–Ί
β—„invert_outputfalseβ–Ί
β—„blur_mask_10.0β–Ί
β—„grow_shrink_mask_10β–Ί
β—„opacity_mask_11.00β–Ί
β—„blur_mask_20.0β–Ί
β—„grow_shrink_mask_20β–Ί
β—„opacity_mask_21.00β–Ί

Compositing more than one mask is where ComfyUI starts to hurt. You want "the subject plus the chair" as a single mask, but you've got two masks, and one has a hard edge while the other is a soft falloff. Mask Composite Pro 2X combines two masks into one with per-mask blur, grow/shrink, and opacity, then merges them with a screen blend - the formula that makes overlapping masks feel like one smooth shape instead of two pasted-together blobs.

How it works

Each mask gets its own preprocessing pass before the merge:

  • blur_mask_N (0–50) - gaussian soften per mask, for feathering edges.
  • grow_shrink_mask_N (βˆ’100 to 100) - morphological grow (positive) or shrink (negative) with an elliptical kernel, to fatten or trim a mask before it meets its sibling.
  • opacity_mask_N (0–1) - per-mask strength before combining.

Then the two processed masks merge via screen blend (1 βˆ’ (1βˆ’a)(1βˆ’b)), which is the "natural union": overlapping areas build up smoothly toward white instead of summing to an ugly hard sum. If the masks have mismatched sizes, the second is resized to match mask_1 automatically - one less thing to babysit.

The outputs and the selector

mask_1 is required, mask_2 is optional (though you might as well feed it). The output_select dropdown is the sleeper feature: all gives you the combined union, but you can also pick 1 or 2 to get just that individual processed mask out of the same node. That's free mask-isolation - no bypassing, no extra nodes. Plus invert_output flips the final result if your pipeline wants inverted masks.

Single mask output, ready to wire into a ConditioningSetMask, a KSampler, or a composite. The in-pack neighbors make this a tidy family: Channel Mask Pro derives channel masks, this node unions them, and Inpaint Mask Pro handles the "crop a sloppy mask to a clean silhouette" case.

Install

MachinePainting Nodes pack:

cd ComfyUI/custom_nodes
git clone https://github.com/machinepainting/ComfyUI-MachinePaintingNodes.git
pip install -r requirements.txt

or ComfyUI Manager β†’ "MachinePaintingNodes" β†’ install β†’ restart.

Gotchas

Screen blending means the union never exceeds full white and never hard-clips - but it also means the overlap region gets brighter than either mask alone, so if you see a bright seam where masks overlap, that's expected screen behavior, not a bug; dial opacity_mask_N down if it's too hot. Grow/shrink is a single morphological iteration, so large values can make edges chunky - pair a big grow with a matching blur to round it out. And remember output_select: 1 returns the processed version of mask 1, not the raw input, so it reflects your blur/opacity tweaks.

CategoryMachinePaintingNodes/Mask

Inputs (10)

NameTypeDefaultDescription
mask_1MASKβ€”
output_selectCOMBOall3 options: all, 1, 2
invert_outputBOOLEANfalseβ€”
mask_2optMASKβ€”
blur_mask_1optFLOAT0.00–50β€”
grow_shrink_mask_1optINT0-100–100β€”
opacity_mask_1optFLOAT1.000–1β€”
blur_mask_2optFLOAT0.00–50β€”
grow_shrink_mask_2optINT0-100–100β€”
opacity_mask_2optFLOAT1.000–1β€”

Outputs (1)

NameTypeDescription
maskMASKβ€”