Latent Compose Mask
The same latent blend, but only where you want it
- latent1
- latent2
- mask
- LATENT
LatentComposeMask is the mask-equipped sibling of this pack's plain LatentCompose node: same two latents, same ratio, same spherical-interpolation (slerp) math - plus an optional mask that decides where the blend actually happens. Leave the mask unconnected and it behaves exactly like the non-mask version. Connect one and you can keep one image's latent untouched in some regions while letting the interpolation take over elsewhere, all still in latent space with no decode/re-encode round trip.
The gotcha that matters: what the mask actually picks
Here's the part people get wrong on the first try. The mask does not select between latent1 and latent2. It selects between latent1 and the slerp result. Looking at the code's blend step: where the mask is black (0), you keep latent1 unchanged; where it's white (1), you get the interpolated latent; gray values give a partial blend in between.
So if you're coming from image-editing land and expect "white means latent2," you'll be confused why the white regions don't show image B. The author's design is "black = keep the base, white = apply the blend." To get latent2 in the white region instead, swap the two inputs and flip the mask, or just reframe what you're doing: you're masking the amount of interpolation, not choosing a source.
How it works
The mechanism is clean. It computes the global slerp between the two latents first, then layers the mask on top. The mask is automatically resized to the latent's spatial dimensions with bilinear interpolation, so you can feed a mask at any resolution and it just works. It's also expanded across all latent channels - all 4 for SDXL, all 16 for a Flux latent - so the same mask behaves correctly regardless of the model's latent channel count. That auto-resize plus channel expansion is the node's real convenience over doing this by hand with LatentComposite-style plumbing.
Inputs and output
latent1,latent2- the twoLATENTtensors to blendratio- global blend point, 0 to 1, default 0.55 (sets how far the white regions go)mask(optional) - aMASKtensor; 0 keeps latent1, 1 applies the interpolation
The single LATENT output feeds a KSampler's latent input or a VAE Decode, same as the plain node.
Installing it
Part of the ComfyUI-LantentCompose pack. Easiest via ComfyUI Manager - search "LantentCompose" and install - or clone it yourself:
cd ComfyUI/custom_nodes
git clone https://github.com/Apache0ne/ComfyUI-LantentCompose
Then restart ComfyUI. The README declares "Dependencies: None," and it means it - no pip installs, no model files, no downloads. The code only uses ComfyUI's own modules.
Common issues
- The mask-semantics trap above is the main one. Remember: black = latent1, white = blend.
- Mask dimension errors. The node expects a mask shaped
[batch, height, width]or[batch, 1, height, width]. A bare 2D[H, W]mask throws aValueErrorstraight out of the source: "Mask must be [batch, height, width] or [batch, 1, height, width]." Most mask-producing nodes emit 3D masks, but if you're building one by hand, add the batch dimension. - Same-shape and same-VAE rules from the plain node still apply. Mixing SDXL latents with Flux latents, or latents from checkpoints with different VAEs, gives you errors or visual garbage regardless of the mask.
It's a thin node - one mask-aware variant of the same trick - but when you want region-controlled latent mixing without pasting pixels, it's exactly the piece you'd otherwise have to assemble yourself.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| latent1 | LATENT | — | |
| latent2 | LATENT | — | |
| ratio | FLOAT | 0.550–1 | — |
| maskopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |