maskCompositeMask Adv
Layering multiple masks together, batches and all
- back
- surface
- mask
- Options
- MASK
- Help
If you've ever wanted to layer two masks the way you'd layer two selections in Photoshop - one sitting "on top" of another, with its own offset and scale - the stock ComfyUI mask-composite tooling gets you partway there. This node is a beefed-up version aimed at the case that actually trips people up: batches of masks that don't line up neatly, and wanting to reposition one mask relative to another rather than just blending them in place.
It's part of ComfyUI-WJNodes, a personal utility pack from an author who signs their GitHub only as 807502278. This particular node is explicitly designed to work alongside a companion settings node the pack calls ImageCompositeMask_Adv's options - you plug an Options object in rather than setting position and scale directly on this node.
What it does
Masking-heavy workflows - the crop-detail-paste pattern used across ComfyUI's whole detailer ecosystem - often need to combine more than one mask before the actual inpainting step: a coarse region mask plus a finer detail mask, say, or a base selection you want a second mask layered onto with some spatial offset. That's this node's job. It takes up to two mask layers (back and surface) plus a third general mask input, applies whatever positioning and scaling the Options object specifies, and blends them into one output mask. Per the author's own framing, it's built to tolerate batch mismatches - different numbers of masks in each input batch - rather than erroring out the moment your batch counts don't match, which is exactly the kind of thing that breaks stock composite nodes when you're chaining automated per-frame or per-detection workflows.
Inputs and outputs
All three mask inputs are optional, which tells you this node is meant to be flexible about which combination you're actually using in a given graph:
- back - the base mask layer.
- surface - the layer composited onto it.
- mask - a general mask input alongside the two named layers.
- Options - an object from the pack's compatible settings node, carrying the positional offset, scale, and batch-handling behavior. Without it, you're relying on the node's defaults for how the layers combine.
Two outputs: MASK, the composited result you wire onward into whatever's consuming it (an inpaint conditioning node, a crop node, another composite), and Help, a plain string. That second output isn't a mask or an error signal - it's a built-in usage note the node returns, which is a small but genuinely handy touch for a node with this many moving parts and no separate documentation page.
Installing it
ComfyUI Manager: search "ComfyUI-WJNodes." Or by hand:
cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-WJNodes.git
Restart ComfyUI. No external models or heavy dependencies for this one - it's pure mask math.
Where this gets fiddly
This is one of the more advanced nodes in the pack, and the complexity is mostly in the Options object rather than this node itself - read that companion settings node's own output before assuming this node is misbehaving. If your composite comes out positioned wrong, that's almost always a scale/offset value set in Options, not a bug here.
Given how little documentation exists beyond the README and no community threads to search, the Help output is worth actually reading the first time you wire this node up - print it to a text preview node and see what the author's own summary of the current settings says, rather than guessing at behavior from the input names alone.
Batch mismatches are the other thing to watch: the node is built to tolerate different mask counts across its inputs, but "tolerate" doesn't mean "does what you assumed" - verify the composited output against what you expected rather than trusting it blind when your back and surface batches are different sizes.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| backopt | MASK | — | |
| surfaceopt | MASK | — | |
| maskopt | MASK | — | |
| Optionsopt | Composite_Basic | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| MASK | MASK | — |
| Help | STRING | — |