Mask Add (UTK)
Add two masks together and clip the result — the 'keep everything' union
- mask1
- mask2
- mask
When you want to inpaint both the face and the hands, or protect two separate regions at once, the move is to combine two masks. Mask Add (UTK) is the pixel-level union operator: mask1 + mask2, clamped to the 0–1 range, so anything covered by either input is covered in the output. It's from the ComfyUI-UniversalToolkit mask trio, and it's the simplest of the three.
If you're new to masks, think of it as "either/or counts." Wherever either mask is white, the result is white. Where both are black, the result stays black. The clamping matters because masks hold values between 0 (black) and 1 (white) - add two half-gray masks and you'd get 1.0 without clamping, which would turn a soft edge into a hard one. The clamp keeps that from happening.
How it works
Under the hood it's a one-liner: torch.clamp(mask1 + mask2, 0, 1), applied elementwise, batch-aware. If the two masks have different shapes it raises a clear error telling you the dimensions don't match - which is the honest thing to do, because silent broadcasting would give you a mask you don't understand. That shape requirement is the one real constraint to remember.
Inputs and outputs
mask1(MASK) - first input.mask2(MASK) - second input. Must matchmask1's dimensions.
Single output: mask (MASK), the union.
Install and gotchas
Install via ComfyUI Manager (search "ComfyUI-UniversalToolkit") or:
cd ComfyUI/custom_nodes
git clone https://github.com/whmc76/ComfyUI-UniversalToolkit
pip install -r requirements.txt
Restart ComfyUI. No models, no keys - torch only.
The classic mistakes: feeding masks of different sizes and wondering why it errors, and expecting this to average the two masks. It doesn't - it's an additive union, so overlapping gray regions can hit the 1.0 clamp and lose their soft edge. If you want a true average (two masks blended 50/50), this isn't the node; if you want "inpaint everything either mask touches," it's exactly right. If your pipeline produces one mask that needs protecting and one that needs painting, remember Add makes the region where either is active get affected - pair it with MaskAnd to build "both must be active" logic.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask1 | MASK | — | |
| mask2 | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |