Shape Mask
Procedural Stencils That Sweep Across the Frame
- video
- shape_image
- video
Masking in ComfyUI usually means one of two things: SAM finding an object, or you drawing a spline by hand. Shape Mask is the third option nobody talks about - a procedural mask, built from math instead of detection or drawing. Under ComfyTV/VideoFX, it generates a grayscale map from gradients and thresholds it into a mask, and because the shape is procedural, it can animate - which makes it the sneaky-good node for vignettes, wipes, and animated transitions that would otherwise need keyframing.
map_kind picks the source function: radial (default) or the linear/bilinear axes - a soft radial falloff from the frame center is the classic vignette shape. threshold (0–1, default 0.5) slices the gradient into a hard stencil, and softness (0–1, default 0.1) blurs that slice so it's a soft-edge mask rather than a hard matte. invert flips it. Then the two knobs that make it a video tool:
animate-static,sweep_in, orsweep_out. The sweep modes push the shape across the frame over the clip, which is exactly the wipe/title-reveal mechanic you'd otherwise build in an NLE.output-stencil(default) ormatte. Stencil vs matte is a classic compositing distinction: a stencil is the sharp thresholded shape; a matte is the softer, graded version with edge falloff. Wire whichever your composite stage expects.
There's also a seed (reproducibility for the animated noise-free variants), and two optional inputs: video (the footage you're masking against - needed for animated modes) and shape_image, which swaps the procedural gradient for any grayscale image you feed it. That's the underrated path: generate a noise or displacement image in another stage, wire it in, and the Shape Mask becomes "threshold this arbitrary map," which is how you get organic, non-gradient masks without any segmentation model.
The practical take
Don't reach for this to isolate a person - that's SAM territory. Reach for it when you want a soft, procedural, animating mask: vignettes, corner reveals, gradient transitions, or "threshold an arbitrary grayscale map." The default is deceptively simple (a radial threshold), and the moment it earns its keep is sweep_in + a slightly lowered threshold for a gentle wipe.
Install
With ComfyTV:
cd ComfyUI/custom_nodes
git clone https://github.com/jtydhr88/ComfyTV
Restart ComfyUI; under ComfyTV → VideoFX. ComfyUI Manager: search "ComfyTV". Desktop/macOS: clone into the running instance's absolute custom_nodes (startup-log path), fix any ComfyTV/ComfyTV/ nesting, full backend restart. No models, no extra deps.
Troubleshooting
- Hard-edged stencil when you wanted a soft mask. Lower
softnessis the dial - wait, the opposite: raisesoftnesstoward 0.3–0.5 for a feathery edge, or switchoutputtomatte. - Animated mode does nothing.
sweep_in/sweep_outneed the clip's duration, so wire thevideoinput; without it there's no timeline to sweep across. - Mask covers the whole frame. Threshold at 0 with a radial map is "everything." Raise
threshold.
Inputs (12)
| Name | Type | Default | Description |
|---|---|---|---|
| force_run_token | INT | 00–2147483647 | Internal — bumped on Run to invalidate ComfyUI's input cache. |
| project_id | STRING | Internal — populated by the projectStore on the frontend. | |
| parent_output_id | INT | 00–2147483647 | Internal — lineage parent set by spawn handlers on the frontend. |
| map_kind | COMBO | radial | 16 options: linear_x, linear_y, bilinear_x, bilinear_y, radial, square, +10 |
| threshold | FLOAT | 0.500–1 | — |
| softness | FLOAT | 0.100–1 | — |
| invert | BOOLEAN | false | — |
| animate | COMBO | static | 3 options: static, sweep_in, sweep_out |
| output | COMBO | stencil | 2 options: stencil, matte |
| seed | INT | 70–99999 | — |
| videoopt | COMFYTV_VIDEO | — | |
| shape_imageopt | COMFYTV_IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| video | COMFYTV_VIDEO | — |