Nodes/ComfyUI Impact Pack/Preview Bridge (Latent)
ComfyUI Node Runs on cloud

Preview Bridge (Latent)

Preview a latent and mask it in-place

By ltdrdata·Created 3 years ago·Updated 4 months ago· 3,242
Preview Bridge (Latent)
  • latent
  • vae_opt
  • LATENT
  • MASK
image
preview_method
blockfalse
restore_mask

This node solves a specific annoyance: you've got a latent mid-workflow, you want to see it, and you want to draw a mask on it without decoding to an image, masking, and re-encoding. Preview Bridge (Latent) shows you a preview of the latent right in the node and lets you open ComfyUI's MaskEditor on it, then passes both the latent and your mask downstream. It's the latent-space cousin of the image PreviewBridge, and it's the clean way to paint an inpaint mask directly onto a latent that's already flowing through your graph.

Because it renders the preview from a latent, it uses ComfyUI's fast latent-to-RGB approximations - you're not getting a full VAE decode by default, just enough to see what you're masking.

How it works

You pass a latent in. The node renders a preview using the chosen preview_method (a lightweight latent-to-RGB conversion, per-model). You right-click and open MaskEditor, draw your mask, and the node stamps that mask onto the latent and also exposes it as a separate output. Per the README's behavior notes: if the incoming latent already carries a mask, it displays that; if it has none, the whole region is treated as masked. When you connect a real vae to vae_opt, that takes priority over the approximate preview and you get a proper decode instead.

The inputs and outputs that matter

  • latent - the latent to preview and mask. The reason the node exists.
  • preview_method - how the preview is rendered (Latent2RGB variants per model family, or TAESD-family decoders). Pick the one matching your model - Latent2RGB-SDXL for SDXL, Latent2RGB-FLUX.1 for Flux, and so on - or the preview will look wrong even though the latent is fine.
  • vae_opt (optional) - connect a VAE for an accurate preview; it overrides preview_method.
  • block (optional boolean) - when set, execution stops if the mask ends up empty. Useful as a guard so you don't run a whole detailing pass on nothing.
  • restore_mask (never / always / if_same_size) - controls whether a mask carried on the incoming latent is restored.

Outputs are LATENT (now carrying your mask) and MASK (the mask on its own), so you can feed the masked latent into a sampler and route the raw mask elsewhere.

How to install it

Comes with the Impact Pack. ComfyUI Manager: search ComfyUI Impact Pack, Install, restart. Manually:

cd ComfyUI/custom_nodes
git clone https://github.com/ltdrdata/ComfyUI-Impact-Pack comfyui-impact-pack
cd comfyui-impact-pack
pip install -r requirements.txt

then restart. The MaskEditor it hooks into is part of ComfyUI itself - the README notes PreviewBridge features need a reasonably current ComfyUI to behave.

Common issues & troubleshooting

The preview looks like garbage / wrong colors. Your preview_method doesn't match the model. The latent-to-RGB approximations are model-specific; pick the variant for your checkpoint family, or plug a matching VAE into vae_opt for a true decode.

The mask I drew didn't take. After painting in MaskEditor you have to save it back to the node, and you need to re-run so the masked latent flows on. If the mask comes through empty and you've set block, execution will halt by design - that's the guard working, not a bug.

It re-runs every time even when nothing changed. PreviewBridge nodes are interactive by nature. If you're using an external seed elsewhere and seeing constant regeneration, the README's advice for the debug detailer applies to the family generally - watch that a randomizing seed upstream isn't forcing everything downstream to recompute.

CategoryImpactPack/Util

Inputs (6)

NameTypeDefaultDescription
latentLATENT
imageSTRING
preview_methodCOMBO13 options: Latent2RGB-FLUX.1, Latent2RGB-SDXL, Latent2RGB-SD15, Latent2RGB-SD3, Latent2RGB-SD-X4, Latent2RGB-Playground-2.5, +7
vae_optoptVAE
blockoptBOOLEANfalseis_empty_mask: If the mask is empty, the execution is stopped. never: The execution is never stopped. Instead, it returns a white mask.
restore_maskoptCOMBOif_same_size: If the changed input latent is the same size as the previous latent, restore using the last saved mask always: Whenever the input latent changes, always restore using the last saved mask never: Do not restore the mask. `restore_mask` has higher priority than `block` If the input latent already has a mask, do not restore mask.

Outputs (2)

NameTypeDescription
LATENTLATENT
MASKMASK