Nodes/ComfyUI_agilly1989_motorway/MaskComposite_motorway_edition
ComfyUI Node

MaskComposite_motorway_edition

Layering masks by hand, without a wire in sight

By agilly1989Β·Created 2 years agoΒ·Updated about a year agoΒ· 7
MaskComposite_motorway_edition
  • MOTORWAY πŸšŒπŸ’¨
  • MOTORWAY πŸšŒπŸ’¨
β—„INPUT_destination_keydestinationβ–Ί
β—„INPUT_source_keysourceβ–Ί
β—„x0β–Ί
β—„y0β–Ί
β—„operationβ–Ύβ–Ί
β—„OUTPUT_MASK_keyMASKβ–Ί

Building a good inpainting region usually means combining masks - a face mask plus a hands mask plus a background carve-out, layered into one. ComfyUI's stock answer is MaskComposite, which the pack renames "Combine Masks". This is its Motorway-ed clone: same operation, but the two input masks arrive by key instead of by wire, and the result is written back into the Motorway rather than handed out on a connector.

What it does

It takes a destination mask and a source mask, positions the source onto the destination at an x/y offset, and combines the overlap using the operation you pick. Think of it as an image-editing blend mode for masks:

  • multiply - the overlap survives; both must be white to stay white. Good for intersection-style regions.
  • add - union-ish; either being white makes the result white (clamped).
  • subtract - carve the source out of the destination.
  • and / or / xor - the bitwise versions, if you like thinking in booleans.

The inputs that matter:

  • INPUT_destination_key (default destination) and INPUT_source_key (default source) - the keys holding the two MASK tensors in the Motorway. Which is "destination" vs "source" only matters for subtract and for where the layer lands, so keep them straight.
  • x and y - where the source gets dropped onto the destination. Both default to 0 and go up to 16384.
  • operation - the dropdown above. Default is multiply, which is the one you usually want for combining inpainting regions.
  • OUTPUT_MASK_key (default MASK) - where the composited mask is stored for the next node to read.

The typical flow: a couple of nodes produce masks (edge detection, color keys, a VAE-decode-and-threshold chain), each stored under its own key, then this node merges them into one MASK that your inpainting conditioning reads. Because everything is keyed, you can re-run any producer without re-wiring anything - that's the whole appeal of the pipe.

Motorway plumbing

The wrapper keeps x, y and operation as real widgets, turns the two mask inputs into INPUT_*_key strings, and swaps the output for OUTPUT_MASK_key. Runtime behavior is identical to the built-in MaskComposite - the clone instantiates the stock node, fetches both masks by key, and stores the result. No behavior lost.

Install

One install for the whole pack. ComfyUI Manager β†’ search "ComfyUI_agilly1989_motorway", or:

cd ComfyUI/custom_nodes
git clone https://github.com/agilly1989/ComfyUI_agilly1989_motorway

Restart ComfyUI. No requirements.txt, no extra deps, no model downloads.

Troubleshooting

  • 'MotorwayClass' object has no attribute 'hash_' - a key you referenced isn't in the Motorway. Confirm the mask producers ran before this node and that the key names match exactly (case matters).
  • If masks are different sizes, x/y behave like a paste offset - the source keeps its own size and overlaps wherever the offset puts it. Misaligned output almost always means the offset is wrong, not the operation.
  • The pack is BETA and the newest published version (1.1.7) disabled clone generation, so on a fresh install these _motorway_edition nodes may be absent from the menu. They're present in the 1.1.0–1.1.6 builds comfy.icu indexed.
Categoryagilly1989 Nodes/Motorway-ed/mask

Inputs (7)

NameTypeDefaultDescription
MOTORWAY πŸšŒπŸ’¨MOTORWAY πŸšŒπŸ’¨β€”
INPUT_destination_keySTRINGdestinationβ€”
INPUT_source_keySTRINGsourceβ€”
xINT00–16384β€”
yINT00–16384β€”
operationCOMBO6 options: multiply, add, subtract, and, or, xor
OUTPUT_MASK_keySTRINGMASKβ€”

Outputs (1)

NameTypeDescription
MOTORWAY πŸšŒπŸ’¨MOTORWAY πŸšŒπŸ’¨β€”