Nodes/ꘇ Genereti/ꘇ top.mask
ComfyUI Node

ꘇ top.mask

Turn any ComfyUI MASK into real alpha (and keep it)

By languel·Created about a month ago·Updated 3 days ago· 1
ꘇ top.mask
  • image
  • mask
  • image
◄channel▾►
◄operation▾►
◄invertfalse►
◄strength1.00►

ComfyUI's mask world and its image world are two different continents. Segmentation gives you a MASK; composition wants alpha; and most nodes on either side don't cross over. top.mask is a bridge: it applies either a native ComfyUI MASK or another IMAGE to the source's alpha channel, with a channel selector, an invert, a strength blend, and the choice between multiplying the existing alpha or replacing it.

That matters more than it sounds, because the KB's background-removal material flags alpha as the fragile part of the pipeline - "not all ComfyUI workflows support RGBA pipeline throughout - some nodes silently drop the alpha channel." A node that deliberately writes alpha, rather than relying on whatever the next node does with it, is the thing you want when a subject keeps landing on black.

How it works

The mask input is a multi-type socket: it accepts a native MASK (a 2D array) or an IMAGE. How it's interpreted depends on which you gave it:

  • Native MASK - used directly as opacity. The node wraps it into an image and reads its red channel, which means your channel selection is effectively bypassed for native masks. That's the behaviour, not a bug, but it's the first thing people report.
  • IMAGE mask - channel picks what to read: luma, alpha, red, green, blue. For luma and the R/G/B choices, the value is multiplied by the mask image's own alpha, so transparent areas of the mask mask out. The alpha channel uses alpha directly.

Then operation decides the marriage. multiply preserves existing transparency - the new mask can only remove, never add. replace sets alpha outright. invert flips the mask, and strength blends between the source's original alpha and the computed alpha, so 0.5 gives you a half-applied mask. RGB is never touched; this node only edits alpha.

The inputs that matter

mask, channel, operation, plus invert/strength. The one to think about is operation: if your source already has alpha you care about (a keyed subject, a differently-masked layer), multiply is almost always what you want; replace throws the old alpha away. One output, image, with alpha attached - so it feeds top.composite naturally.

The typical chain: segment → top.mask on your plate → top.composite over a new background. Or, in the pack's own idiom, use it to feather a region-specific effect: crop a region, grade it, mask the crop's edges, composite it back.

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, refresh the page. Single frontend pin, no downloads. It's ꘇ top.mask in Genereti / TOP; search genereti because the name starts with a glyph that sorts weirdly. The pack's top.blobs also produces masks in this same family if you need to find objects rather than apply them.

Traps

The mask is resized to the source, not the other way round. Whatever resolution your mask arrives at, it's stretched to fit the image. A tiny segmentation mask upscales into a soft blob - resize deliberately if you care about the edge.

channel silently does nothing for native MASKs. As above: a 2D mask is forced to the red channel. If your channel setting appears ignored, that's why.

Alpha still has to survive to disk. This node hands a four-channel image downstream; whether it lands depends on the Save/Preview node at the end. If the file is opaque, look there, not here.

Live vs Queue. Live runs on the browser GPU (WebGPU required); Queue runs the PyTorch path, which is where native MASK inputs are the natural fit. Live intermediate textures are 8-bit, Queue keeps float.

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

CategoryGenereti / TOP

Inputs (6)

NameTypeDefaultDescription
imageIMAGE—
maskIMAGE,MASK—
channelCOMBO5 options: luma, alpha, red, green, blue
operationCOMBO2 options: multiply, replace
invertBOOLEANfalse—
strengthFLOAT1.000–1—

Outputs (1)

NameTypeDescription
imageIMAGE—