Nodes/TrentNodes/Latent-Aligned Mask (No VAE)
ComfyUI Node

Latent-Aligned Mask (No VAE)

When you know the compression already

By TrentHunter82·Created 9 months ago·Updated 4 days ago· 36
Latent-Aligned Mask (No VAE)
  • mask
  • aligned_mask
  • latent_preview
compression_factor8
expansion_pixels8
blur_latent_units1
threshold0.50

The "with VAE" version of this pack's latent-aligned mask is the smart one - it probes your VAE and figures out the compression factor for you. Latent-Aligned Mask (No VAE) is the pragmatic one: you tell it the compression factor directly, it skips the whole detection dance, and you get the same latent-aligned, blocky-edged mask with one less wire and zero chance of a misread VAE.

Why would you want that? Because for the two families that matter, the answer is boring and stable. Wan and SD-family models are 8×. Most everything else worth the effort is 4×. You don't need a VAE object crawling your model graph to know which one you're on - the tooltip on the compression_factor input says it verbatim: 8 for Wan/SD, 4 for others.

Inputs

  • mask - your source mask.
  • compression_factor - the spatial compression, 1–16, default 8.
  • expansion_pixels - mask growth in latent units, default 8. This is the anti-black-edge control.
  • blur_latent_units - boundary softening, default 1.
  • threshold - binary cutoff, default 0.5.

The processing pipeline is identical to the VAE version - area-downsample to latent res, max-pool expansion, Gaussian blur, threshold, nearest-neighbor upsample back to full res. Same math, same blocky edges that land exactly on the latent grid. What you give up is the auto-detect and the compression_factor INT output (the VAE version reports what it found, which is a nice debugging aid).

Outputs

aligned_mask is the one you wire into an inpainting sampler. latent_preview is the downsampled, pre-threshold view - genuinely handy when you're diagnosing "why does my mask look soft" because it shows you exactly what the latent saw before the binary cut.

Install

Ships in TrentNodes:

cd ComfyUI/custom_nodes
git clone https://github.com/TrentHunter82/TrentNodes.git
cd TrentNodes
pip install -r requirements.txt

Restart and find it under Trent/Masks. Like its siblings, pure tensor math, no model downloads.

When to reach for it instead of the VAE version

If you're on Wan or SD and you're tired of dragging VAE connections around just to produce a mask, this is the one. The "with VAE" node exists for when you don't trust the compression factor - mixed pipelines, unusual VAEs, debugging. But honestly, for 95% of latent inpainting, 8× is 8×, and this node is the leaner path. The edge case to respect: if you're working with a 4× VAE and leave it at the 8 default, your mask edges will misalign and you'll chase phantom seam artifacts. Set the number, don't trust the default blindly.

CategoryTrent/Masks

Inputs (5)

NameTypeDefaultDescription
maskMASK
compression_factorINT81–16Spatial compression (8 for Wan/SD, 4 for others)
expansion_pixelsINT80–64Expand mask in LATENT space (prevents black edges)
blur_latent_unitsINT10–8Blur amount in latent units (softens boundaries)
thresholdFLOAT0.500–1Binary threshold after processing

Outputs (2)

NameTypeDescription
aligned_maskMASK
latent_previewMASK