πΎ Mask Composite Pro 2X
Two masks, one clean union
- mask_1
- mask_2
- mask
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.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| mask_1 | MASK | β | |
| output_select | COMBO | all | 3 options: all, 1, 2 |
| invert_output | BOOLEAN | false | β |
| mask_2opt | MASK | β | |
| blur_mask_1opt | FLOAT | 0.00β50 | β |
| grow_shrink_mask_1opt | INT | 0-100β100 | β |
| opacity_mask_1opt | FLOAT | 1.000β1 | β |
| blur_mask_2opt | FLOAT | 0.00β50 | β |
| grow_shrink_mask_2opt | INT | 0-100β100 | β |
| opacity_mask_2opt | FLOAT | 1.000β1 | β |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | β |