ComfyUI Node

Nuke Keymix

The mask-driven blend node that behaves like Nuke's Keymix

By sumitchatterjee13·Created about a year ago·Updated 9 days ago· 59
Nuke Keymix
  • A
  • B
  • mask
  • IMAGE
invert_maskfalse
mix1.00

Keymix is the compositing move everyone eventually needs: two images, one mask, and wherever the mask is white you see image A and wherever it's black you see image B - with a smooth blend in between. If you've ever faked it with a merge node and a matte, this is the cleaner tool that does exactly the one job, the way Nuke's Keymix node does.

The setup is dead simple: A and B images, a mask, done. It's a linear interpolation - A * mask + B * (1 - mask) - which means the mask value at each pixel is literally the blend ratio between the two images. A soft-edged mask gives a soft-edged transition, no bleed-through guessing required. That's the whole mechanism, and it's exactly why it's worth using instead of improvising: no blend modes, no operation dropdown, just "how much of A shows through here."

When you'd reach for it

  • Replacing a sky: A is your new sky, B is the original image, mask is the sky matte.
  • Compositing a generated foreground over a background with a soft edge.
  • Any time a merge with a mask is doing the same thing but with more knobs and more ways to go wrong.

There's one conceptual distinction that trips people up, and the node's own docs spell it out: a merge node with a mask still runs a blend operation (over, multiply, screen…) and the mask only controls how much of that result replaces B. Keymix does no blend operation at all - it's pure interpolation between A and B, so what you see is a direct crossfade between the two images. When you want a clean crossfade, Keymix is the more predictable tool.

The inputs that matter

  • A - foreground, fully visible where the mask is 1.
  • B - background, fully visible where the mask is 0. B also defines the output resolution: if A is a different size, A gets resized to match B, which is the Nuke convention.
  • mask - a MASK type, the blend ratio. Soft masks, smooth transitions.
  • invert_mask - swaps A and B at every pixel. One click instead of inverting the mask upstream.
  • mix - overall opacity of the effect. The tooltip says it best: mix=0 returns B unchanged, mix=1 applies the full mask blend, and intermediate values lean toward B. So you can keymix at full strength and then dial back how much of the keymix you actually want.

The single output is an IMAGE - A and B (and the mask) all get resized and channel-padded to agree, then blended.

Installing it

Keymix ships with the Nuke Nodes pack:

cd ComfyUI/custom_nodes
git clone https://github.com/sumitchatterjee13/nuke-nodes-comfyui.git nuke-nodes
cd nuke-nodes
pip install -r requirements.txt

Or search "Nuke Nodes" in ComfyUI Manager and restart. It shows up under the Nuke category. Pure PyTorch, no extra dependencies to worry about beyond what the pack installs.

Common issues

  • "A never appears" - check mix. If it's 0 you're getting pure B. The default is 1, but a loaded workflow may have changed it.
  • Transition is hard-edged when you wanted soft - the mask is doing its job; your mask edge is hard. Feather the mask, not the node.
  • Result looks cropped or misaligned - A is resized to match B's resolution, so if A was a wildly different aspect ratio it's been stretched. Match your input aspect ratios upstream.

For sky swaps, face replacements over clean plates, or any "these two images, this matte" job, this is the node that makes the intent obvious and the output predictable.

CategoryNuke/Merge

Inputs (5)

NameTypeDefaultDescription
AIMAGE
BIMAGE
maskMASK
invert_maskBOOLEANfalseInvert the mask (swap A and B at every pixel).
mixFLOAT1.000–1Overall opacity of the keymix. mix=0 returns B unchanged; mix=1 applies the full mask blend; intermediate values blend toward B.

Outputs (1)

NameTypeDescription
IMAGEIMAGE