Nodes/ꘇ Genereti/ꘇ top.key
ComfyUI Node

ꘇ top.key

Pull a green screen matte in ComfyUI, with despill built in

By languel·Created about a month ago·Updated 3 days ago· 1
ꘇ top.key
  • image
  • image
◄mode▾►
◄red0.00►
◄green1.00►
◄blue0.00►
◄low0.10►
◄high0.30►
◄invertfalse►
◄despill0.00►
◄output▾►

Chromakeying in ComfyUI usually means either a learned background remover (great, occasionally wrong, always a download) or hand-rolled luminance math that never quite works on an unevenly lit screen. top.key is the middle path: a classic RGB-distance chroma key and a luminance key, with a soft ramp, an invert, a despill, and a choice of whether you get the cut-out image or the matte itself. No model, no download, and it works on any image you can load.

That last option is the reason to care. The KB's background-removal material notes that a lot of ComfyUI silently drops the alpha channel, and that RGBA support is uneven across the ecosystem - so a key that hands you both a matte and an alpha-carrying image, in a graph whose nodes are explicitly alpha-aware, is more useful than it sounds.

How it works

Two modes, chosen with the mode combo:

  • chroma - measures the normalized Euclidean RGB distance from each pixel to your key colour (defaults to pure green: green 1, the others 0) and builds a matte with a smoothstep ramp between low and high. Near the key colour the matte goes to zero, so chroma mode removes colours close to the key and keeps the rest.
  • luma - builds the matte from luminance instead, keeping values above the ramp. Use this for white/black screens or for pulling a glow.

invert flips the matte. despill (0..1, chroma only) is the one people forget to touch: it finds the dominant channel of your key colour and pulls it out of the kept pixels, weighted by how transparent that region is - which is precisely the green rim you get on hair and reflective edges. If your cut-out has a green halo, despill is the fix, not the matte.

output decides what comes out: image multiplies the original alpha by the matte and leaves RGB intact; matte returns an opaque greyscale mask with alpha forced to 1. Same computation, two shapes - grab the matte for a compositor or a downstream mask, grab the image for an immediate composite.

The linear-ish part to understand: low and high are your softness. Move them together for a tighter key with more fringe; spread them apart for a softer, more forgiving one that eats more of the subject edge.

The inputs that matter

mode, then the key colour via red/green/blue, then low/high for the ramp. despill only matters in chroma mode. One output, image - either the keyed picture or the matte, depending on output.

Wire it into top.composite (as A, over a new background - that's the canonical chain), into top.mask if you want to reuse the matte against another source, or into top.edge/top.emboss for a cut-out-safe effect pass.

Install

ComfyUI Manager → search ꘇ Genereti → install, or:

git clone https://github.com/languel/genereti.git custom_nodes/genereti
./.venv/bin/python -m pip install -r custom_nodes/genereti/requirements.txt

Restart Comfy and refresh the browser. One frontend dependency, no models - which is the appeal over a learned matting model for screening work where you control the lighting. It's registered as ꘇ top.key under Genereti / TOP; the leading glyph sorts badly, so search genereti.

Traps

Lighting changes your key. The distance is measured in RGB, so a green screen that goes from bright to shadowed keys at two different thresholds. Set low/high for the darkest part of your screen, or light your screen evenly.

Green in the subject goes with the screen. Foliage, green clothing, green eyes - anything within the ramp distance is removed. Tighten low/high and expect to fix the rest with despill.

despill does nothing in luma mode. It's chroma-only, and the widget doesn't disable itself, which is a small trap.

Alpha dies downstream. Same warning as everywhere else in this pack: the keyed image carries alpha, but a lot of ComfyUI plumbing drops it before you save. Check your Save/Preview node if the subject lands on black.

Live vs Queue. Live runs on the browser GPU (WebGPU required); Queue runs PyTorch. Live intermediates are 8-bit, Queue keeps float, so a fringe-detail comparison can differ slightly between the two.

Pack status: super-alpha, early classroom testing. Back up your workflows.

CategoryGenereti / TOP

Inputs (10)

NameTypeDefaultDescription
imageIMAGE—
modeCOMBO2 options: chroma, luma
redFLOAT0.000–1—
greenFLOAT1.000–1—
blueFLOAT0.000–1—
lowFLOAT0.100–1—
highFLOAT0.300–1—
invertBOOLEANfalse—
despillFLOAT0.000–1—
outputCOMBO2 options: image, matte

Outputs (1)

NameTypeDescription
imageIMAGE—