Nodes/OmniNodes/Latent Mask 🎭 (TensorVizion)
ComfyUI Node

Latent Mask 🎭 (TensorVizion)

Draw a Mask Straight on the Latent and Skip the Round Trip

By TensorVizionΒ·Created 3 months agoΒ·Updated about 8 hours agoΒ· 0
Latent Mask 🎭 (TensorVizion)
  • latent
  • mask
  • latent
  • mask_out
β—„mask_shapeβ–Ύβ–Ί
β—„blend_modeβ–Ύβ–Ί
β—„x0.25β–Ί
β—„y0.25β–Ί
β—„width0.50β–Ί
β—„height0.50β–Ί
β—„feather0.05β–Ί
β—„clamp_value1.0β–Ί
β—„invert_maskfalseβ–Ί
β—„seed0β–Ί

Most masking in ComfyUI happens in pixel space: you draw on the image, then VAE-encode both together for inpainting. Latent Mask cuts out the round trip. It generates a rectangle, ellipse, or gradient mask in latent space and applies it directly to the latent tensor - zeroing a region, filling it with noise, clamping it, whatever you ask for. The coordinates are all fractions of the latent's size, so you get a mask that would look right on the decoded image without ever touching pixel space.

How it works

Pick a mask_shape - rectangle, ellipse, horizontal or vertical gradient, or external to supply your own MASK. Then pick what happens inside the masked region with blend_mode:

  • zero - wipe it to 0. Full erase, the "make this region blank" move.
  • noise - fill with Gaussian noise. This is the one that sets up an inpaint-style regeneration.
  • clamp - clamp values to Β±clamp_value. Softens extreme values in a region.
  • invert - multiply by βˆ’1. Bizarre and usually a mistake, but it's there.

Position and size are normalized fractions: x, y, width, height in 0–1 space, so a rectangle at x=0.25, y=0.25, width=0.5, height=0.5 is a centered box covering the middle half. feather softens the mask edge (0–0.5, default 0.05) - small values are usually enough; heavy feathering bleeds the effect into surrounding areas. invert_mask flips inside/outside, and seed makes the noise mode deterministic.

Inputs and outputs

  • latent - in.
  • mask_shape, blend_mode, x/y/width/height, feather, clamp_value, invert_mask, seed - the controls.
  • mask (optional) - supply your own when shape is external.
  • latent - the masked result. mask_out - the mask it used, in case you want to reuse it downstream.

Where it fits

The flagship use is latent-space inpainting prep: mask a region, fill with noise, then sample with a prompt focused on that area - the noise gives the sampler something to build from, and because you never left latent space, nothing got lost to an encode/decode round trip. Pair it with the pack's KSampler Masked Inpaint if you'd rather hand over an image + mask and let that node do the whole encode-and-sample dance.

It's also a handy tool for structure experiments: mask out a chunk, zero it, and see what the model does with the hole. And it's cheap - no VAE work, just tensor math.

Install and troubleshooting

Same as the rest of the pack - pure PyTorch, no extra deps:

cd ComfyUI/custom_nodes
git clone https://github.com/TensorVizion/OmniNodes

Restart, find it under TensorVizion/Latent (ComfyUI Manager, search "OmniNodes", works too).

One genuinely pack-specific gotcha: latent_mask_node.py had a real syntax error in earlier releases - four lines of unseparated statements - that made the entire file fail to import. It's fixed as of the pack's 2026-07-30 update, but if you installed an old copy and this node is missing from your menu, git pull and restart. Check the terminal for [OmniNodes] ❌ Syntax Error lines to diagnose.

  • The mask doesn't line up with your image. Fractions are relative to the latent, and the latent is 8x smaller per side than the image - but the same fraction maps to the same proportional location, so a 0.5 box is the middle half of both. If things look offset, check invert_mask and feather.
  • Noise mode looks chaotic. It's latent-space Gaussian noise, not visible pixel noise. At high strength the decoded result will look more like static than grain - lower the noise's role by sampling at lower denoise, or use zero if you wanted a clean hole.

Latent Mask is the kind of node that feels niche until you need it, and then it's the difference between a two-node detour and a one-node straight line. Worth having in the toolbox for any latent-space work.

CategoryTensorVizion/Latent

Inputs (12)

NameTypeDefaultDescription
latentLATENTβ€”
mask_shapeCOMBO5 options: rectangle, ellipse, gradient_h, gradient_v, external
blend_modeCOMBO4 options: zero, noise, clamp, invert
xFLOAT0.250–1β€”
yFLOAT0.250–1β€”
widthFLOAT0.500–1β€”
heightFLOAT0.500–1β€”
featherFLOAT0.050–0.5β€”
clamp_valueFLOAT1.00–10β€”
invert_maskBOOLEANfalseβ€”
seedINT00–4294967295β€”
maskoptMASKβ€”

Outputs (2)

NameTypeDescription
latentLATENTβ€”
mask_outMASKβ€”