Pixelwise(MASK - MASK)
Cut one mask out of another
- mask1
- mask2
- MASK
Boring name, boring node, and I mean that as a compliment - it does exactly one thing and never surprises you. Pixelwise(MASK - MASK) subtracts mask2 from mask1. Wherever the second mask is white, it gets erased from the first. That's it. It's the mask equivalent of "everything in A that isn't also in B."
You reach for it constantly once you're doing any real masking work. Masked the whole person but want to exclude their face from a pass? Subtract the face mask. Selected a region but need to punch a hole in it? Subtract the hole. It's plumbing, and like most good plumbing you only notice it when it's missing.
How it works
Masks in ComfyUI are grayscale - white is "included," black is "excluded," grays are partial. This node does pixelwise subtraction: for each pixel, mask1 minus mask2, clamped so it can't go below zero. Areas covered by mask2 are removed from mask1; areas only in mask1 stay. Nothing fancy, no settings to get wrong.
The inputs and outputs that matter
Two inputs, and the order is the whole story:
mask1- the mask you're keeping. The base.mask2- the mask you're cutting out ofmask1.
Swap them and you get the opposite result, so if the output looks inverted from what you wanted, that's almost always it.
The single output is MASK - the difference, ready to feed anywhere a mask goes (a detailer, an inpaint, another mask operation).
How to install it
Ships with the Impact Pack. ComfyUI Manager: search ComfyUI Impact Pack, Install, restart. Manually:
cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack comfyui-impact-pack
cd comfyui-impact-pack
pip install -r requirements.txt
then restart. No models or extra dependencies - it's pure array math.
Common issues & troubleshooting
The result is the inverse of what you expected. You've got mask1 and mask2 swapped. Subtraction isn't symmetric: A - B keeps A, B - A keeps B. Flip the inputs.
Nothing gets subtracted. The two masks probably don't overlap, or they're different sizes. Both masks need to be the same resolution - resize one to match the other upstream if they came from different sources. If mask2 is empty (all black), there's nothing to subtract and you'll just get mask1 back unchanged.
Ragged edges after subtraction. The subtraction is exact, so hard edges in either input carry straight through. If you want a soft boundary, blur or feather the result afterward (Gaussian Blur Mask), or feather the masks before subtracting. And remember this is the plain two-mask operator - if you're working with SEGS (detected-region bundles) rather than raw masks, the SEGS-level subtract node is the one you want instead.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mask1 | MASK | — | |
| mask2 | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |