Mask And (UTK)
The 'both must be covered' mask operator for intersection logic
- mask1
- mask2
- mask
Sometimes you need the overlap, not the union. You have a subject mask and a "lower half of the frame" mask, and you want to affect only the part where both are true. Mask And (UTK) is that intersection operator: mask1 * mask2, elementwise. Where either input is black, the result is black. Only where both are white does the output stay white.
It's part of the ComfyUI-UniversalToolkit mask trio (And, Add, Sub), and together they're the boolean logic of your masking layer. And is the one that says "both," which is the constraint you reach for when a region needs to pass two filters at once.
How it works
The implementation is a direct tensor multiply - mask1 * mask2 - with no clamping needed, because multiplying values in the 0–1 range can never exceed 1. That makes it the mathematically cleanest of the three operations: a soft edge on one mask times a soft edge on the other gives a naturally softer combined edge, no artifacts. Like its siblings, it requires both inputs to have identical shapes and errors clearly if they don't, and it's batch-aware.
Inputs and outputs
mask1(MASK) - first input.mask2(MASK) - second input, same shape.
Single output: mask (MASK), the intersection.
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.
The mental model to keep straight: And = where both are true, Add = where either is true. If you wire And where you meant Add, your inpaint silently shrinks to only the overlap, which usually looks like "nothing happened" and sends you on a debugging wild goose chase. Also, And multiplies, so overlapping grays get darker - two half-strength masks overlapping produce 0.25, not 0.5. If you find yourself fighting that, you want a different operator. For the classic case - "only inpaint where the face mask and the region mask agree" - And is exactly right.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask1 | MASK | — | |
| mask2 | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| mask | MASK | — |