Combine Masks
Your mask-building workbench, with an offset
- destination
- source
- MASK
Combine Masks is where masks get built rather than drawn. It pastes one mask onto another at an offset, with six operations to choose from - multiply, add, subtract, and, or, xor. If you've ever needed the union of two selections, or a face mask carved out of a hair mask, or a small region placed onto a big canvas, this is the node. It's the mask-world equivalent of ImageCompositeMasked, and it's the piece that turns separate detection masks into one coherent inpaint mask.
Why you'll reach for it
Most mask workflows start with several region masks - a face mask, a hair mask, a background mask, each from its own detector or paint. Almost no workflow wants those as separate masks. You want one mask that says "regenerate all of this." Combine Masks is the glue.
The operation dropdown is the whole personality:
- multiply - intersection. Both masks must be active. Use it when a pixel belongs only if both regions say so.
- add - union, but it can exceed 1.0 and gets clamped. The casual way to merge regions.
- subtract - carve one region out of another. The classic: take the full body mask, subtract the face mask, and you get "everything but the face."
- and / or / xor - boolean logic on rounded values. These operate on masks as if they were binary (any value above roughly 0.5 counts as true), which gives you clean set operations without worrying about partial overlap adding up.
And then there's x and y, which is what makes it more than a combine tool. You place source onto destination at an offset - which is how you take a small face-region mask and stamp it at the right position on a full-frame canvas. Pair it with SolidMask as the blank destination and you've got a paste tool.
How it works
The destination is the canvas; the source is what gets placed onto it. The source's overlapping region is combined with the destination's at that location using the chosen operation, and the final result is clamped to 0.0–1.0. Only the overlap region is affected - the rest of the destination passes through untouched. The boolean operations round before comparing, so they behave like thresholded sets; the arithmetic ones preserve soft values.
The inputs and outputs
destination- the base mask, the canvas.source- the mask being placed onto it.x,y- where the source lands on the destination (top-left).operation- multiply, add, subtract, and, or, xor.
One output, MASK.
Getting it
Core ComfyUI, nothing to install. It's in comfy_extras/nodes_mask.py with the rest of the mask family.
Where people get burned
- Order matters.
destinationandsourceare not symmetric forsubtractor for placement. "subtract source from destination" is not the same as "subtract destination from source." If your result is inverted, you swapped them. - The boolean ops are hard.
and/or/xorround to binary, so soft feathered masks lose their edges the moment they go through these. Usemultiplyif you want to keep gradients. - Offsets outside the canvas get clipped silently. The source just disappears past the destination's edge. If something's vanishing, check your
x/yagainst the canvas size.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| destination | MASK | — | |
| source | MASK | — | |
| x | INT | 00–16384 | — |
| y | INT | 00–16384 | — |
| operation | COMBO | 6 options: multiply, add, subtract, and, or, xor |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |