You are here: User Guide > Nuke > 3D Compositing > Merging Shaders

Merging Two Shader Nodes

With the Shader menu’s MergeMat node, you can combine two shader nodes together, using compositing algorithms like none, replace, over, and stencil. The MergeMat node is particularly useful for combining multiple Project3D nodes, allowing you to composite 2D images projected onto the 3D geometry atop each other.

To Merge Two Shaders

1.   Select 3D > Shader > MergeMat to add a MergeMat (over) node after the two shader nodes you want to combine.
2.   Connect the MergeMat node to the img input of the 3D object you want to project the images on.
3.   Connect the shader nodes to the MergeMat node’s A and B inputs. A refers to the foreground element, and B to the background element.

For example, if you wanted to combine two Project3D nodes and composite their results onto a sphere, your node tree would look something like the following:

4.   From the operation dropdown menu, select how you want to composite the results of the two shader nodes together:

to only use input B in the composite, select none.

to only use input A in the composite, select replace.

to composite input A over input B using a mask, select over.

to use input B outside the mask area, select stencil.

to use input B inside the mask area, select mask.

to add input B to input A, select plus.

to use input A if it is greater than input B or else use input B, select max.

to use input A if it is less than input B or else use input B, select min.

5.   For operations (such as over) that need an alpha channel (mask), select which channel to use for the alpha from the Alayer dropdown menu.