Nodes/ComfyUI-CustomNodePacks/Shuffle — Channels (MEC)
ComfyUI Node

Shuffle — Channels (MEC)

Remap RGBA in one node

By Code2Collapse·Created 6 months ago·Updated a day ago· 52
Shuffle — Channels (MEC)
  • image
  • image
  • alpha
out_RR
out_GG
out_BB
out_AA
premultiply_outputfalse

In Nuke, the Shuffle node is the boring workhorse every compositor reaches for: repoint any output channel at any input channel - swap R and B, drive alpha from luminance, invert a channel - all in one node. ShuffleMEC brings exactly that to ComfyUI, and it's one of the more useful pieces of the ComfyUI-CustomNodePacks pack for anyone doing compositing-style work.

The name is the whole pitch: "Nuke-style 4-channel shuffle in a single node." The author's own comment in the source is even blunter - it's meant to replace the multi-node Rube Goldberg machines people build with separate math nodes just to swap a channel, which they rather colorfully call a "DUMB_BLUR / MULTI_NODE_SHUFFLE diagnosis." If you've ever stacked three Split/Combine nodes to swap R and B, you are the target audience.

How it works

ComfyUI images are (B, H, W, C) tensors, and most workflows only ever touch RGB. ShuffleMEC lets you set each of the four output channels (out_R, out_G, out_B, out_A) to any of eleven sources: the input's R, G, B, A, a computed Lum (Rec.709-style luminance, 0.2126R + 0.7152G + 0.0722B), the inverses InvR/InvG/InvB/InvA, or constants zero/one. All four assignments happen in a single forward pass, so it's fast and atomic.

The subtle bit most people miss: ComfyUI's IMAGE type is RGB. If you feed an RGB image, there is no alpha channel, so selecting A or InvA synthesizes one - the source code falls back to a constant 1.0 for A when the input has fewer than four channels. That's a feature (you can build an alpha from nowhere) but it's also the thing that confuses people when they shuffle "A" and get a solid white mask.

Inputs and outputs that matter

  • image - the input batch.
  • out_R, out_G, out_B, out_A - the source for each output channel. Defaults are the identity (R, G, B, A), so the node passes through unchanged until you touch it.
  • premultiply_output (BOOLEAN, default false) - when on, the RGB result is multiplied by the output alpha. Use this when you're emitting RGBA that a downstream compositor will un-premultiply.

Outputs:

  • image (IMAGE) - the shuffled (B, H, W, 4) RGBA result.
  • alpha (MASK) - the output alpha channel, pulled out separately so it can feed mask-based nodes directly.

The alpha output is the sleeper feature: since you can build A from luminance or an inverted channel, this node doubles as a luminance key or channel inverter with a mask output free.

Installing it

Standard pack install:

cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks.git

restart ComfyUI (or use Manager → "CustomNodePacks"), confirm [MEC] Loading MaskEditControl node pack … in the console. No dependencies beyond what ComfyUI ships - skip the pack's requirements.txt unless the mask/VAE nodes are in your future, since a blind install can overwrite ComfyUI's torch/numpy.

The trap

Remember there's no real alpha in most ComfyUI images - A sources are synthesized, not stored. If you're feeding an actual RGBA PNG (which ComfyUI can load with its own alpha handling), shuffle honors it; otherwise expect A to be a constant 1.0 until you build it from something. And set premultiply_output deliberately - leaving it off with a dark alpha makes for muddy RGB when you composite downstream.

CategoryMaskEditControl/Channels

Inputs (6)

NameTypeDefaultDescription
imageIMAGE
out_RCOMBOR11 options: R, G, B, A, Lum, InvR, +5
out_GCOMBOG11 options: R, G, B, A, Lum, InvR, +5
out_BCOMBOB11 options: R, G, B, A, Lum, InvR, +5
out_ACOMBOA11 options: R, G, B, A, Lum, InvR, +5
premultiply_outputBOOLEANfalse

Outputs (2)

NameTypeDescription
imageIMAGE
alphaMASK