Shuffling Channels

You can use Nuke's Shuffle node to rearrange the channels from a single image (B input) or two images (B and A inputs) and then output the result to the next node in your compositing tree. Select Channels > Shuffle or press Tab in the Node Graph and type Shuffle to create a Shuffle node.

The Shuffle node can:

rearrange up to eight channels from a single image (B input). For example, you can use it to swap rgba.red for rgba.green,

rearrange channels between two separate nodes (A and B input), like a foreground and background branch,

replace a channel with black (removing the alpha channel, for example) or with white (making the alpha solid, for example),

create new channels.

The Input Layer represents the channel sets connected to the B and A inputs and the Output Layer represents what is passed down the node tree. You can drag noodles from sockets in either direction to connect the input and output layers. Nuke displays a preview of the resulting noodle connection in white when you drag sockets.

Note:  Channels that are valid, but are not connected to the current node tree are displayed as dotted lines.

You can change the layer order by dragging the icon and dropping the layer in its new position. Changing the order of layers can help with script organization so that you can keep the first output layer for swapping channels in the current data stream and the second output layer for creating new channels.

Shuffle Examples

A simple Shuffle in a single image might be copying the red channel of an rgba layer into its alpha channel. Using Shuffle, drag the red input socket to the alpha output socket to copy the channel.

Tip:  If you just need to copy a channel from one data stream into another, you can also use Channel > Copy, instead of Shuffle. Then, specify the channel to copy and the destination channel for output. See Copy for more information.

A slightly more complex Shuffle from two images might be replacing the B input's alpha channel with the A input's alpha channel.

The Shuffle node's Properties panel.

Channels from B Input - the first group of channels are supplied by the B input on the node.

Channels from A Input - the second group of channels are supplied by the A input on the node.

To shuffle the alpha channel from A into the output layer and ignore the alpha from B, do the following:

1.   Click Channel > Shuffle to insert a Shuffle node.
2.   Select the incoming channels from the Input Layer. You can select up to eight channels in this manner.
3.   Select the layer to which you wish to direct the incoming channels from the dropdown menus on the right. You can select up to eight channels here as well.

Note:  If the outgoing layer to which you wish to direct channels does not yet exist, create it using the new option on the dropdown menus on the right.

4.   Connect the noodles as required to shuffle the channels. In this example, we disconnect the B input's alpha channel and connect the A input's alpha channel. The resulting output layer consists of the rgb channels from B and the alpha channel from A.

Tip:  While not required, it’s good practice to use the first output layer for swapping channels in the current data stream and the second output layer for creating new channels. This protects the default rgba channel set from unintentional overwriting, and makes it easier for other artists to understand the workings of your script.

Shuffle Keyboard Shortcuts

Dragging noodles between sockets can be time consuming in large scripts, so Shuffle includes a number of time-saving shortcuts.

Description

Action

Result

Auto-connect all channels

Drag and drop

Auto-connect by order

double-click

Auto-connect by channel name

Ctrl/Cmd + double-click

Connect a channel and all lower channels in the layer

Ctrl/Cmd + drag

Connect a channel and all higher channels in the layer

Ctrl/Cmd + Shift + drag

Broadcast an input channel to all output channels

Alt + drag

Set all output channels to full black (0) or full white (1)

Ctrl/Cmd + click

Assigning Constants

The Shuffle node can also assign black (0) or white (1) constants to any incoming channel. So, for example, to reset the alpha channel to a full-frame image, enable the full white button:

Assigning constants to channels.

Tip:  You can also use Ctrl/Cmd + click to set all output channels to full black (0) or full white (1).

Creating Swap Layers

Finally, if the layer to which you wish to output channels does not yet exist, you can create it using the new option on the dropdown menus on the right. Once you select the new option, you follow the same process for creating layers as is described under Creating Channels and Layers.