VFX I

52.2 Nuke Assembly


Our first task in compositing is to assemble the render passes to re-compose the original beauty

The point of using passes is to gain more control in color correction, so our next step is to look into the workflow of adding color correction nodes to the passes



Basic Assembly

Testing materials with diffuse, specular, transmission, subsurface (skin), coat and emission

Assembly couldn’t be easier: All passes are merged with PLUS, the sum is the original beauty

The order of nodes in a plus-operation is irrelevant

In the above example, none of the passes have an alpha channel, therefore default Merge operation OVER would work as well


Assembly with Alpha

In most cases, we will render layers, i.e. foreground layer on black with alpha channel

Renders on black are usually premultiplied


Premultiplied
Simply put, any semi-transparency in the alpha, even one-pixel anti-aliasing, has already been applied to the RGB channels in the premultiplied image

Unpremultiplied
Full colors in RGB image, transparency removed


Why is this relevant?

Color correction of premultiplied images create a number of issues

The most obvious: Lifting the blacks will cause the image to not be properly premultiplied anymore – a premultiplied image has to have a fully black background. The default Merge operation OVER will not work anymore as the lifted blacks are plus’ed over the entire background

(More examples on the premultiplication page)

 

1. Color correction of premultiplied images require un-premultiplication first
2. Premultiply and unpremultiply require an alpha channel

Without alpha, there’s nothing to multiply or divide with



1. Unpremult First

Unpremult – Premult bracketing of color correction nodes

Alpha channel is required, here embedded in the beauty

Without alpha Unpremult – Premult can’t work


Maya AOV Default RGBA Channels

Per default, render passes are set to RGB and have no alpha channel

Only the beauty is set to RGBA and comes with alpha


2. Unpremult Requires Alpha Channel

If render passes have no alpha, we need to add the alpha to the render pass before Unpremult

Copy node takes the alpha from input A

Hotkey K to create a Copy node


Unpremult All Passes

Concluding, we need Copy and Unpremult for all render passes before color correction

This setup works as long as alpha and render pass match

Here they match because the material is visible in all passes

 


Alpha has to match render pass

Below example will not work correctly. All object are visible in the alpha channel, but objects vary in the material passes

Lifting the blacks in the Grade node i.e. of the Diffuse pass, which has only two objects, causes blacks of all objects to be lifted, see GRADE_RESULT node. The Premult after the Grade is not working correctly because the alpha includes objects which are not in the diffuse pass


Alpha from RGB Matte

Additional RGB mattes rendered from Maya are very useful. They allow to access every object individually, or in below example to create the missing alpha channels

The RGB mattes are shuffled in new layers (channel-sets), which are merged into the passes and then accessed with the expression node to build the alphas

Note that the GRADE_RESULT is good now, the Premult node works with the correct alpha

The plus operations merge alphas from all passes together, means the final alpha is rubbish. Important to copy the original alpha into the result after plus’ing the passes


Alpha from Expression

1 – This is what we need, alpha for the diffuse pass, created from green + blue of RGB1

 

Shuffle

2- Select new in output layers dropdown

3 – Assign a name for the new layer, i.e. the name of the matte pass

Use short names, need to type them into expressions nodes later

4 – Auto-fill with rgba channels. Exact channel names, here RGB1.red etc. are created after OK

 

Merge

The Merge node should only add the layers, not change the RGB of B input, thus we set A input to none

5 – A channels: none
6 – also merge: all

 

Expression

The last row is the default for the alpha output

7 – Equal field: Add the channels needed

Syntax is layer.channel + layer.channel

 

The second Expression is just another example, from the specular pass of my setup



Minus Methode

Instead of PLUS’ing passes together, we could also use the MINUS operation to change one pass

In this example, the specular pass is first substracted from the beauty, graded and then added back to the beauty

The Merge node operation from is simply B-A

Either remove the alpha before Merge or untick alpha for the A input in Merge


Resources

Nuke Essential Training – Working with channels (login ntulearn first)