Mask Composite Plus β‘π ‘π π £π
Combine two masks with eight different operations
- mask1
- mask2
- MASK
ComfyUI ships a basic mask composite node, and this is RyanOnTheInside's beefed-up version - same core idea, combine two masks into one, but with a much wider menu of operations than the usual add/subtract pair. If you're layering multiple masks (a subject mask plus a depth-limited region, say, from this same pack's Flex Mask Depth Chamber) this is the node that merges them into a single mask you can actually use.
How it works
Two masks in, one operation applied pixel-by-pixel, one mask out. No thresholds, no strength dial, no feature reactivity - this is a straight, deterministic combine, which is exactly what you want when you're composing masks logically rather than blending them artistically.
The inputs and outputs that matter
mask1andmask2(MASK, both required) - the two masks to combine.operation- eight choices:add,subtract,multiply,divide,min,max,pixel_wise_min,pixel_wise_max. The arithmetic ones (add/subtract/multiply/divide) behave like you'd expect from basic image math.min/maxandpixel_wise_min/pixel_wise_maxare worth knowing apart: in practice,min/maxon masks is standard shorthand for a pixel-wise comparison too, but having both pairs explicitly listed suggests the pack distinguishes a scalar-style min/max from a strictly per-pixel one - if the distinction matters for your use case, test both on a simple two-circle mask pair and compare, since it's a one-second check that removes any doubt.- Output - a single
MASK.
How to install it
Via ComfyUI Manager: search "RyanOnTheInside," install, restart. By hand:
cd ComfyUI/custom_nodes
git clone https://github.com/ryanontheinside/ComfyUI_RyanOnTheInside.git
cd ComfyUI_RyanOnTheInside
pip install -r requirements.txt
then restart ComfyUI. No downloads needed - pure mask math.
Common issues & troubleshooting
add produces a mask that's blown out to solid white in overlapping regions. That's expected - adding two masks means overlapping white regions can exceed the maximum value and clamp. If you want the union of two masks without that blowout, max (take the brighter of the two at each pixel) is usually the operation you actually want instead of add.
subtract leaves negative values or unexpected black regions. Subtracting a mask that's brighter than the base in some area than pushes those pixels toward (or past) zero - this is the standard "cut mask2's white areas out of mask1" operation, useful for excluding a region (say, cutting a depth-limited chamber out of a full subject mask) rather than for symmetric blending.
divide gives you unpredictable or extreme results. Division is the one operation here that can blow up toward infinity wherever mask2 is near zero - if you're getting garbage output, divide is the first operation to suspect, and it's rarely what you actually want unless you specifically understand why you need it.
Not sure which operation to reach for. For a straightforward "combine two regions into one" (union), start with max. For "keep only where both masks agree" (intersection), start with multiply or min. Those two cover the large majority of real mask-combining use cases; the rest are there for the less common cases.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| mask1 | MASK | First input mask (MASK type) | |
| mask2 | MASK | Second input mask (MASK type) | |
| operation | COMBO | Operation to combine masks ('add', 'subtract', 'multiply', 'divide', 'min', 'max', 'pixel_wise_min', 'pixel_wise_max') |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | β |