Nodes/ComfyUI_agilly1989_motorway/LatentCompositeMasked_motorway_edition
ComfyUI Node

LatentCompositeMasked_motorway_edition

Paste a latent onto a latent, constrained by a mask

By agilly1989·Created 2 years ago·Updated about a year ago· 7
LatentCompositeMasked_motorway_edition
  • MOTORWAY 🚌💨
  • MOTORWAY 🚌💨
INPUT_destination_keydestination
INPUT_source_keysource
INPUT_mask_keymask
x0
y0
resize_sourcefalse
OUTPUT_LATENT_keyLATENT

LatentCompositeMasked_motorway_edition wraps the masked sibling of LatentComposite: it pastes a source latent onto a destination latent, but only inside the region defined by a mask - and it can resize the source to fit first. The motorway edition pulls all three inputs (destination, source, mask) out of pipe keys and stores the result back under a key.

The mask is the point

Plain LatentComposite is a rectangular paste; this node is the one you reach for when the region you want to fill isn't a rectangle. The mask is what decides where the source lands - think patching a face region, filling an irregular inpaint zone, or compositing a person back into a scene where a hard box would clip them. The workflow pattern is the same as all latent compositing: do the placement in latent space, then let a sampling pass blend the seam so the boundary disappears.

Two inputs matter beyond the three keys:

  • x / y (step 8, default 0) - placement position in latent coordinates, not pixels. Latents are 8x smaller per side, so a 512px offset is 64 here; the step of 8 is a hint that these are latent-space values.
  • resize_source (default false) - when on, the source latent is resized to match the mask's bounding box before compositing. Turn it on when your source piece is a different size than the hole you're filling - off, and mismatched sizes either paste partially or error out.

The key fields are INPUT_destination_key ("destination"), INPUT_source_key ("source"), and INPUT_mask_key ("mask"); the output is OUTPUT_LATENT_key (default "LATENT"). Destination is the canvas, source is the piece, mask is the stencil. If you've done masked compositing in pixels, nothing here is new - it's the same mental model one layer of abstraction down.

Motorway notes

Every input is a key field, so all three values must exist in the pipe before this node runs. The only output socket is MOTORWAY 🚌💨; read the result out via a Motorway AxB ramp to sample or decode it. And the standard failure mode applies: a missing or mistyped key throws 'MotorwayClass' object has no attribute 'hash_' - with three keys feeding in, that's usually a mismatch between the mask's key and what your masker actually wrote.

Install and reality check

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

Restart ComfyUI, or install via ComfyUI Manager. No pip deps, no models.

The pack-wide caveats: one-developer beta, README-frank about breakage, and the current repo HEAD has the _motorway_edition registration commented out mid-refactor - so a fresh clone may not show this node at all. The KB's inpainting guidance is the reason you'd use masked latent compositing in the first place (blend the region in latent space before sampling, don't just paste pixels), but none of that changes the recommendation for the wrapper: if masked compositing is the only motorway-ed node in your graph, the stock LatentCompositeMasked does the identical job with sockets and fewer moving parts.

Categoryagilly1989 Nodes/Motorway-ed/latent

Inputs (8)

NameTypeDefaultDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨
INPUT_destination_keySTRINGdestination
INPUT_source_keySTRINGsource
INPUT_mask_keySTRINGmask
xINT00–16384
yINT00–16384
resize_sourceBOOLEANfalse
OUTPUT_LATENT_keySTRINGLATENT

Outputs (1)

NameTypeDescription
MOTORWAY 🚌💨MOTORWAY 🚌💨