ApplyMaskLatent
Composite two latents before the VAE ever sees them
- destination
- source
- mask
- LATENT
The pixel-space ApplyMask works on decoded images. This is its latent-space twin: same blend math, but on LATENT tensors, before the VAE decode. Where mask is 1 you get the source latent, where it's 0 you get the destination, and it operates on the samples inside the latent dict. Output is a LATENT, ready to feed a decoder (or another sampler).
Why would you composite in latent space instead of pixels? Two reasons that actually matter in ComfyWarp-style workflows. First, it avoids a decode–re-encode round trip: if you're blending latents - say, a freshly sampled latent with a warped previous one - you can composite them directly and decode once, instead of decoding both, blending, and re-encoding. That's a real quality win, because VAE encode/decode isn't lossless. Second, it's the natural place to combine two diffusion outputs that never had pixel versions, like blending two sampler results at different denoise strengths.
Mechanically it's the same destination × (1−mask) + source × mask, except the mask gets bilinear-interpolated to the latent's spatial size first - latents are 8× smaller than pixels, so a pixel-resolution mask has to be downsampled to match. The mask is optional on paper, but again: always wire it, or you're compositing with a degenerate mask.
Inputs and the one catch
destination/source- LATENTs. These are thesamplesinside each latent dict; the node unwraps them, blends, and re-wraps.mask- a MASK, resized internally to the latent dimensions. Note it resizes without any blur, so a hard-edged mask can land on latent pixels sharply - if you see blocky seams, feather the mask upstream (MixConsistencyMaps' blur, or a blur node) before it hits this.
The resolution caveat is the usual one: destination and source latents must share spatial dimensions for the elementwise multiply to make sense. Within one pipeline that's automatic - the same VAE and same resolution produce the same latent shape. Cross pipelines (a latent from a different-size sampler) and you'll get a shape error that reads like gibberish until you realize one branch was upscaled and the other wasn't.
So: pixels or latents? If your source and destination both exist as images, use ApplyMask. If either side is still a latent - or you want to avoid the decode round-trip - this is the node. And if you only need the composite on a subset of frames, grab ApplyMaskLatentConditional instead; this one composes every time it's called.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| destination | LATENT | — | |
| source | LATENT | — | |
| maskopt | MASK | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| LATENT | LATENT | — |