Comfy Pro Alpha Generator
SelectiveMatte is just the old name for Comfy Pro Alpha Generator
- images
- alpha
- comp
If you came here looking for SelectiveMatte, the first useful thing I can tell you is that the node changed its name. SelectiveMatte is the class id this thing shipped with, and it still works - ComfyUI keeps it registered so workflows saved months ago open and run. In the node menu you'll find it as Comfy Pro Alpha Generator, under the Comfy Compositing category. Same node, same inputs, new id.
What it does is the annoying half of compositing: pull one chosen person out of a plate, with hair. Not "the foreground" - one subject, of your choosing, with generative-quality edges.
Why this node exists at all
Background removal is the most commoditised job in this ecosystem, and the frontier moved years ago from "can it find the subject" to "can it survive hair, fur and semi-transparency" (that framing is straight out of our background removal writeup, and it's still accurate). SAM3 solved the finding. It did not solve the edges - a mask is a per-frame measurement, and measurement doesn't invent strands that the segmentation outline never contained.
Meanwhile the generative approach got the edges right and the subject wrong: LTX-2.5's alpha-gen IC-LoRA renders hair-level alpha, but it mattes every main subject in the frame and there's no way to point at one. Three kids with their arms around each other? You get three kids.
This node is the splice. SAM3 decides which subject. LTX decides how the edge looks. The author measured the gap on a 247-frame plate: a plain SAM3 mask recovers 29% of the hair outside its own outline, SAM3 + ViTMatte gets to 45%, and this gets to roughly 89%.
How the mechanism actually works
The trick isn't "run both and blend". It's that LTX can't be told which subject to matte, so the node changes what LTX sees. SAM3 finds every other subject and they get painted out of a copy of the plate with inpainted background - not a flat colour fill, because LTX reads a flat fill as a semi-transparent object and mattes it wrong. LTX then mattes your subject alone, and draws all of its edges, including the parts SAM3 missed.
Where your subject touches someone else, LTX returns 1.0 on both sides and there's no edge to take, so within a small band the node substitutes a stabilised ViTMatte edge. A low-res coverage map catches the pieces LTX refused to read as a main subject - a parked car, a table - and fills only those with ViTMatte. SAM3 and ViTMatte work frame by frame and therefore chatter, so their output is warped and averaged across neighbouring frames with optical flow before the blend. LTX renders 49 frames in one go, so its edges are already steady.
At run time the node expands into a full graph of SAM3, ViTMatte and LTX nodes, each cached separately. That's why flipping quality after a render is cheap: the passes that didn't change get reused.
The inputs you'll actually touch
images is the plate - Load Video → Get Video Components, a Load Plate Sequence, or any crop/resize chain. fps and first_frame ride along from whichever loader you used; first_frame is what keeps VFX numbering (1001 in, alpha_01001 out).
You don't set picks by hand. The viewer writes that JSON when you click the subject - click to pick, shift-click to add a part SAM3 missed, alt-click to cut someone else's hand out of the mask.
quality is Best (v12, 2 LTX passes) or Fast (v7, 1 LTX pass). Fast is roughly half the time and fine for look-dev; edges against other people are a bit weaker. render at preview chunk gives you the first 49 frames from your pick frame and appends _preview to filename_prefix.
The model selectors expect specific files (ltx_model, alpha_lora, video_vae, audio_vae, vitmatte) and show MISSING: <file> rather than silently falling back to something unrelated - which matters, because a Flux VAE crashes deep inside LTX with a useless error. text_encoder defaults to the built-in empty prompt; leave it there, alpha-gen's prompt is empty and the pack ships that conditioning so nobody loads a 13 GB encoder for nothing.
Under the optional group sit the interesting switches: overlap_mode for people crossing your subject, native_edges for plates above 1080p, edge_colour (quick / perfect / off), which rebuilds the subject's own colour in the soft edges, clean_plate_lora for perfect, plus the tuning that only matters once overlap mode is on - v13_depth, hair_guide, attn_grow, occluder_reach, limb_cap.
Outputs
Two: alpha (MASK) and comp (IMAGE). alpha is the 16-bit matte, and the node also writes files to ComfyUI/output/<filename_prefix>/ itself - png16 or half-float exr, plus rgba_ comp frames since v0.5. The comp output is only built if you actually wire something to it; on a full 1080p shot that's several gigabytes, so the node checks first.
Install
ComfyUI Manager → Install via Git URL → https://github.com/rik-python/ComfyUI-Comfy-Pro-Alpha-Generator.git. By hand:
cd ComfyUI/custom_nodes
git clone https://github.com/rik-python/ComfyUI-Comfy-Pro-Alpha-Generator.git
pip install -r ComfyUI-Comfy-Pro-Alpha-Generator/requirements.txt
Then install ComfyUI-SAM3 and ComfyUI-LTXVideo, accept the two gated Lightricks licenses on Hugging Face, and download about 25 GB of weights into models/diffusion_models, models/loras and models/vae. SAM3, ViTMatte and Depth Anything download themselves. You need ComfyUI 0.38 or newer - the node is built on the V3 node API. The pack is free for personal and non-commercial use; commercial work needs a license from the author.
Where people get burned
The one that wastes an afternoon: you crop the plate (or swap the clip) after picking, and the picks still look fine but land in the wrong place. The node fingerprints the plate and prints the plate changed since the subject was picked to the console - check there before you blame the model.
After a ComfyUI restart, the small proxy images the picker scrubs are gone from temp/, so the viewer can only show boxes until you click Load plate again. Normal, not a bug.
Long shots hit a hard ceiling: more than 24 chunks and the node stops with a message telling you to lower overlap frames or split the shot. At the defaults that's about 960 frames.
And if alpha is empty for the first part of your shot - it's meant to be. The matte starts at the frame you picked on; everything before it comes out empty.
Inputs (38)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | The plate. Connect Load Video -> Get Video Components, Load Plate Sequence, or any crop/resize chain. Then click 'Load plate' in the node. Best quality at 1920x1088 (a 1920x1080 plate is padded to 1088 automatically): LTX alpha-gen is tuned for that size. Bigger plates (4K, DCI, 2K) are matted on a 1080p proxy, with the edges rendered again at native resolution (native-resolution edges). Smaller plates work, but edges can come out softer. | |
| fps | FLOAT | 24.0001–240 | Plate frame rate (connect Get Video Components / Load Plate Sequence fps) |
| first_frame | INT | 10–10000000 | Frame number of the first image (1001 for VFX plates): output files use it |
| quality | COMBO | Best (v12, 2 LTX passes) | 2 options: Best (v12, 2 LTX passes), Fast (v7, 1 LTX pass) |
| render | COMBO | full shot | preview chunk = first 49 frames from the pick frame |
| picks | STRING | {} | Set by the picker; JSON. |
| filename_prefix | STRING | comfy_pro_alpha/shot | — |
| format | COMBO | png16 | 2 options: png16, exr |
| ltx_model | COMBO | Recommended: ltx-2.5-22b-distilled-transformer-comfy-int8-convrot.safetensors | folder: ComfyUI/models/diffusion_models/ (press R after adding files) | Low RAM/VRAM: LTX-2.5-Distilled-Q4_K_M.gguf (needs the ComfyUI-GGUF node pack); keep models on an NVMe SSD so ComfyUI streams them from disk | |
| alpha_lora | COMBO | Recommended: ltx-2.5-22b-ic-lora-alpha-gen-0.9.safetensors | folder: ComfyUI/models/loras/ (press R after adding files) | |
| text_encoder | COMBO | built-in empty prompt (no text encoder needed) | built-in empty prompt (no text encoder needed): same result, skips loading the 13 GB encoder. Or pick gemma4-12b-with-proj-ltx-2.5-comfy-int8-convrot.safetensors from ComfyUI/models/text_encoders/ |
| video_vae | COMBO | Recommended: ltx-2.5-video-vae-conv-bf16.safetensors | folder: ComfyUI/models/vae/ (press R after adding files) | |
| audio_vae | COMBO | Recommended: ltx-2.5-audio-vae-bf16.safetensors | folder: ComfyUI/models/vae/ (press R after adding files) | |
| vitmatte | COMBO | Folder in ComfyUI/models/vitmatte/, or auto-download on first run | |
| chunk | INT | 499–145 | LTX renders the shot in chunks of this many frames (8n+1). 49 fits 1920x1088 on 32 GB. |
| overlap | INT | 90–72 | Frames shared by neighbouring chunks and cross-faded so the joins don't show. More = smoother joins but more chunks (slower). 9 = a new chunk every 40 frames. |
| seed | INT | 420–2147483647 | — |
| erode | INT | 100–64 | — |
| dilate | INT | 151–64 | — |
| near_px | INT | 151–64 | v7 zone around other excluded subjects (Best) |
| stabilize_radius | INT | 20–6 | Removes frame-to-frame chatter in the SAM3/ViTMatte edges: each frame is averaged with this many frames before and after, warped by optical flow (occlusions are ignored). 0 = off, 2 = default (5-frame window). Higher is smoother but fast motion can lag or ghost, and it is slower. LTX edges are already stable. |
| sam3_threshold | FLOAT | 0.300–1 | — |
| fast_attention | BOOLEAN | true | Comfy Kitchen int8 attention for LTX: about 36% faster sampling, matte difference ~0.004 (7x smaller than changing the seed). Turn off to use standard PyTorch attention. |
| clean_plate_loraopt | COMBO | Recommended: ltx-2.5-22b-ic-lora-clean-plate-1.0.safetensors | folder: ComfyUI/models/loras/ (press R after adding files) | Only for edge colour = perfect; without it perfect runs as quick | |
| overlap_modeopt | BOOLEAN | false | For people crossing the subject (hands, arms, hair). LTX mattes the subject and everyone else on the real plate (3 LTX passes instead of 2, plus a depth pass) and subtracts the others where SAM3 and depth say they are in front: their fingers and curls come out crisp instead of soft. Replaces the quality setting. If a limb of the subject that rests on someone goes missing, add a click on it. Needs other subjects picked; without them it runs Best (v12). |
| v13_depthopt | BOOLEAN | true | Depth Anything V2 Small decides who is in front where SAM3 gives a pixel to both people or neither (fingers over a chest). Off = SAM3 alone (a local vote): faster, but fast thin fingers in front of the subject can ghost. |
| hair_guideopt | BOOLEAN | false | Overlap (v13) only. Where someone's hair crosses the subject, re-fit their hair matte to the plate's own edges (guided filter): more single strands, cleaner gaps between curls. Can read dark stripes or patterns on the subject's clothes as hair, so check the comp. Off by default. |
| hair_radiusopt | INT | 41–16 | How far the hair sharpening looks for plate edges. Smaller = finer strands but noisier; larger = smoother but picks up more clothing pattern. |
| attn_growopt | INT | 200–80 | How far each SAM3 mask is grown before it steers LTX's attention, so hair outside the SAM outline is still matted. Tested best: 20. |
| attn_bluropt | FLOAT | 10.00–40 | Feather of that attention mask. 0 = hard edge (cuts hair, ~1.5x error). Tested best: 10. |
| attn_strengthopt | FLOAT | 1.000–1 | How strongly LTX follows the attention mask. Lower lets it drift to other people. Tested best: 1.0. |
| occluder_reachopt | INT | 200–60 | How far past an in-front person's overlap the subtraction reaches, to catch their soft edge (strands, fast fingertips). Larger can bite the subject's own thin parts. Tested best: 20. |
| limb_capopt | INT | 9020–400 | LTX also draws parts of the subject it cannot see (amodal). Anything further than this from the SAM3 selection is removed (fades over the last 40 px). Raise it if real edges far from the selection get cut. Tested best: 90. |
| front_smoothingopt | INT | 31–9 | Frames averaged so the in-front / behind decision never pops. 1 = off. Tested best: 3. |
| native_edgesopt | BOOLEAN | true | Plates bigger than 1920x1088: LTX also renders the subject's edges on native-resolution 1920x1088 tiles, for strand-level detail at the plate's own size. Roughly 2-3x the render time on a 4K plate. Off: matte at 1080p and scale the alpha up (fast). Plates at 1080p or smaller are not affected. Plates only a little bigger than 1080p (up to about 2300 px wide, e.g. 2K) gain little detail for the full tile cost: switch it off there to save time. |
| edge_colouropt | COMBO | quick | quick: rebuilds the colour of the soft edges from the subject itself, so sky or grass behind hair does not stay in the strands (CPU, no extra VRAM: about 2 s a frame at 1080p, 4 s a frame at 4K). perfect: LTX Clean Plate rebuilds the background, which is then subtracted from the edges (one extra LTX pass per chunk on the 1080p proxy, plus about 2 s a frame at 4K; needs the Clean Plate IC-LoRA). off: the raw plate in the edges, as v0.4.1. The alpha is the same in every mode. Saves rgba_ files next to the alpha. |
| track_backwardopt | BOOLEAN | true | Full shot: matte the whole plate. Every pick is tracked backward to the first frame as well as forward, so you can pick the subject on any frame where it is clear. Frames before the subject enters get an empty alpha. Off: the shot starts at the pick frame (as before v0.6). The preview always starts at the pick frame. |
| skip_sam3opt | BOOLEAN | false | Plain LTX alpha-gen: no picks, no SAM3. LTX mattes every main subject in the plate, and you still get the chunked full shot, native 4K edges, edge colour and EXR with plate frame numbers. The preview starts at the scrubber frame. Quality and overlap mode do not apply. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| alpha | MASK | — |
| comp | IMAGE | — |