ComfyUI Node

VNCCS Chroma Key

The node that actually makes your sprites transparent

By AHEKOT·Created 10 months ago·Updated 20 days ago· 1,446
VNCCS Chroma Key
  • image
  • image
  • matte
  • edge_debug
tolerance0.20
softness0.16
despill_strength0.50
edge_width3
matte_cleanup0.20
foreground_recover0.35
edge_decontaminate0.70
edge_choke0.20
matte_methodguided_edge
screen_modeauto
output_modestraight_rgba
use_sam3_recovery_maskfalse

VNCCS generates every character against a flat, solid backdrop on purpose, because keying a solid color out cleanly is a much more tractable problem than asking a general-purpose segmentation model to guess where a background ends and hair strands begin. This node is the payoff for that choice, and it's not a minor utility inside the pack - when AHEKOT was asked on Reddit whether the transparency in VNCCS 3.0 came from some clever ControlNet trick, his answer was blunt: "It's not. For transparency it uses my chromakey node with SAM3 restoration." This is that node.

Chroma keying is the old broadcast-TV trick - green screen, blue screen - reworked for AI-generated sprites where you actually control the background color choice going in. It reads the border pixels of the image to figure out what that background color is, then builds a soft alpha matte around it, cleans the matte up along the edges, and tries to recover foreground detail (hair especially) that got contaminated by the background color bleeding onto it. That's a genuinely harder problem than it sounds - see the background-removal writeup on why hair and fine edges are still the unsolved case for every segmentation model in this space, chroma key included.

The inputs that matter

Most of the eleven required sliders are fine-tuning knobs you'll never touch - the defaults are sane. The ones actually worth adjusting:

  • tolerance (default 0.2) and softness (0.16) - how close a pixel has to be to the detected background color to count as background, and how gradual the falloff is at the edge. Raise tolerance if patches of background survive; raise softness if edges look hard and jagged.
  • screen_mode (default auto) - auto-detects green, blue or red from the image borders. Force it manually if your character's outfit or hair happens to be close to the actual backdrop color and auto-detect picks the wrong channel.
  • despill_strength (0.5) and edge_decontaminate (0.7) - despill removes background color that's bled onto the edges of the subject (a green fringe on blond hair, for instance); edge decontamination is a second, narrower pass focused only on the boundary pixels.
  • use_sam3_recovery_mask (default off) - the SAM3 restoration AHEKOT mentioned. Runs Meta's Segment Anything 3 over the result to recover foreground detail the chroma math alone would have cut into, at the cost of a slower pass. Worth it for anything with clothing or eye colors close to your backdrop.
  • matte_method (default guided_edge) - chroma_soft is the plain distance-from-background alpha; guided_edge refines it against the image's own edges, which is why it's the default; pymatting_if_available hands off to the pymatting library's alpha-matting solver if it's installed, otherwise silently falls back.

Three outputs: image (the keyed RGBA result), matte as a standalone MASK you can wire into other nodes, and edge_debug, an image specifically for inspecting how the edge cleanup behaved - pull this up before you trust a batch run.

How to install it

It ships as part of the main pack, no separate download:

  • ComfyUI Manager - search VNCCS - Visual Novel Character Creation Suite, install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/AHEKOT/ComfyUI_VNCCS.git, then cd ComfyUI_VNCCS_Utils && pip install -r requirements.txt, restart, then click "Install missing custom nodes" in Comfy Manager once for the companion dependencies.

Common issues

Green or blue fringing survives on hair. Push despill_strength and edge_decontaminate up before reaching for anything heavier - that's exactly what those two settings exist for. If it's still not enough, turn on use_sam3_recovery_mask.

Auto screen detection picks the wrong color. Happens when your character's costume has a large flat area close to the backdrop hue. Set screen_mode explicitly instead of trusting auto.

The matte looks fine in the preview but falls apart when composited onto a colored background in-engine. Check output_mode - straight_rgba (the default) keeps color and alpha independent, which is what you want for most game engines; premultiplied_rgba bakes the alpha into the color channels and will look wrong if your engine expects straight alpha. Match it to whatever your sprite pipeline downstream actually expects.

CategoryVNCCS

Inputs (13)

NameTypeDefaultDescription
imageIMAGE
toleranceFLOAT0.200–1
softnessFLOAT0.160.001–1
despill_strengthFLOAT0.500–1
edge_widthINT30–32
matte_cleanupFLOAT0.200–1
foreground_recoverFLOAT0.350–1
edge_decontaminateFLOAT0.700–1
edge_chokeFLOAT0.200–1
matte_methodCOMBOguided_edge3 options: chroma_soft, guided_edge, pymatting_if_available
screen_modeCOMBOauto4 options: auto, green, blue, red
output_modeCOMBOstraight_rgba2 options: straight_rgba, premultiplied_rgba
use_sam3_recovery_maskBOOLEANfalse

Outputs (3)

NameTypeDescription
imageIMAGE
matteMASK
edge_debugIMAGE