Latent-Aligned Mask (Wan 2.1)
Presets in pixel space
- mask
- aligned_mask
Wan 2.1's VAE is always 8× spatial compression. No detection needed, no surprises. Latent-Aligned Mask (Wan 2.1) is the version of this pack's mask family that bakes that fact in and then does you one better: its presets are expressed in pixel space, not latent units, so you're tuning in the units you actually see.
Where the base node asks for expansion_pixels and blur_latent_units (latent-space numbers that feel abstract), this node gives you standard (64px expansion, 8px blur), tight (32px, none), and loose (96px, 16px), then converts to latent internally by dividing by the compression factor. The names say it all: tight hugs the mask, loose gives the sampler room to play.
Inputs
- mask - your source mask.
- preset -
standard,tight,loose, orcustom. Standard is the sane default for most Wan inpainting. - expansion_pixels / blur_pixels - only read when preset is
custom. Both are multiples of 8 (the tooltip is explicit about it), which is a nice guardrail - it keeps you in latent-aligned territory automatically.
One output: aligned_mask, the binary, blocky-edged mask ready for a latent inpaint.
Why Wan specifically
Wan video inpainting is one of the most common latent-mask use cases going, and it's also where the black-edge artifact bites hardest - you're often masking across frames, and a misaligned edge flickers frame to frame in a way you notice immediately. The Wan variant hardcodes the 8× factor so there's no auto-detect step to misfire, and the pixel-space presets mean the numbers in the UI map directly to how much of your subject you see covered. No mental math.
Install
Ships in TrentNodes:
cd ComfyUI/custom_nodes
git clone https://github.com/TrentHunter82/TrentNodes.git
cd TrentNodes
pip install -r requirements.txt
Restart, find it under Trent/Masks.
Gotchas
First: the presets live in pixel space but the custom sliders are the same fields, just multiplied out - set a preset, switch to custom, and you'll see the resolved pixel values staring back at you. That's a handy way to learn what the presets actually do. Second: like every node in this family, the output is binary after thresholding; there's no feather knob here, so if you want soft edges, add your own blur downstream. Third - and this is the real one - this node aligns the mask to the spatial latent grid only. It does not handle Wan's temporal dimension or the 4×+1 frame-count padding that Wan pipelines need. That's a separate concern; this pack covers it with its Wan2.1 Frame Adjuster, but don't expect it from a mask node.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | MASK | — | |
| preset | COMBO | standard | standard=64px, tight=32px, loose=96px, custom=use sliders |
| expansion_pixelsopt | INT | 640–256 | Expansion in PIXEL space (only if preset=custom). Multiple of 8! |
| blur_pixelsopt | INT | 80–64 | Blur in PIXEL space (only if preset=custom). Multiple of 8! |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| aligned_mask | MASK | — |