Tuesday, May 28, 2013

How to use Unpremult and Premult nodes in Nuke 7

In this tutorial, you will learn about the premultiplication and when to use it in your composition. When you composite CGI images, you must be aware of premultiplied vs unpremultiplies images otherwise some artifacts can appear such as dark edges around the composited CGI object. Also, some edge artifacts may appear after the color correction. Most the rendered images that modern day 3D applications produce are premultiplied. In such images,the RGB channel is already multiplied by the its alpha channel. Therefore, it should not be multiplied again while compositing it in post. If you are composting a CGI image having semi-transparent alpha pixels, all color pixels will be scaled down and thus become darker. While applying color-correction on a premultimplied image, you might get artifacts where semi-transparent areas exist in the image. To overcome this problem, you should first apply an unpremultiply operation and then premultiply the image again after color-correction. In Nuke, the Permult node is used to premultiply the input image. This node multiplies the rgb channels of the input image with its alpha channel. An input image that is not premultiplied is referred to as straight or unpremultiplied. If the black areas in the alpha channel are not black in the color channels, then the image is considered as straight. The Unpremult node is used to divide the rgb channels of the input image by its alpha. Lets first start with how the Multiply operation of the Merge node works in Nuke.

Step - 1
Navigate to the following link http://www.mediafire.com/download/ubzwukea7cql8w7/nt005.zip and download the zip file. Next, extract the butterfly.jpg and jet.tif from the zip file to your hard drive.

Step - 2 
Start Nuke and then create a new script by choosing File > New from the menu bar.

Step - 3
Hover the cursor over the Node Graph panel and press S; the Project Settings panel will be displayed in the Properties Bin. Make sure the Root tab is chosen and then select NTSC_16:9 720x486 1.21 from the full size format drop-down.

Next, you will import images to the script.

Step - 4
Choose the Image button from the Nodes toolbar; the Image menu will be displayed. Next, choose Read from this menu; the Read File(s) dialog box will be displayed. In this dialog box, navigate to the location where you have saved the butterfly.jpg and then choose the Open button; the Read1 node will be inserted in the Node Graph panel.

Step - 5
Make sure the Read1 node selected in the Node Graph panel and then press 1 to view the output of the Read1 node in the Viewer1 panel, as shown in Figure 1.
Figure tu5-1 The output of the Read1 node
Figure 1 The output of the Read1 node
Step - 6
Choose the Transform button from the Nodes toolbar; the Transform menu is displayed. Next, choose Reformat from this menu; the Reformat1 node will be added to the Node Graph panel and a connection will be established between the Read1 and Reformat1 nodes.

Step - 7
Select the Reformat1 node in the Node Graph panel and then add Transform node from the Transform menu; the Transform1 node will be inserted between the Reformat1 and Viewer1 nodes.  In the Transform tab of the Transform1 node properties panel, enter 90 in the rotate field and 0.56 in the b field; the output of the Transform1 node will be displayed in the Viewer1 panel, as shown in Figure 2.
Figure tu5-2  The output of the Transform1 node
Figure 2  The output of the Transform1 node
Step - 8
Click on the empty area of the Node Graph panel and then choose the Draw button from the Nodes toolbar; the Draw menu will be displayed. Next, choose Radial from this menu; the Radial1 node will be added to the Node Graph panel.

Step - 9
Press 1; the output of the Radial1 node will be displayed in the Viewer1 panel. Next, adjust the shape of radial ramp, as shown in Figure 3.
The radial ramp
Figure 3 The radial ramp
Step - 10
Make sure the Radial1 node is selected in the Node Graph panel and then connect a Multiply node with the Radial1 node; the input A of the Multiply node will be connected to the Radial1 node.

Step - 11
Drag-drop the Multiply node on the pipe connecting the Transform1 and Viewer1 nodes; the input B of the Multiply node will be connected with the Transform1 node.

Notice the result of the multiply operation in the Viewer1 panel. The result of the Transform1 node is gradually appearing darker from center to the edge of the frame. Next, you will use the Premult node. First, combine the RGB and alpha channels using a Copy node.

Step - 12
Delete the Multiply node from the Node Graph panel and then select the Radial1 node. Next, press K; the Copy1 node will be inserted in the Node Graph panel and the input A will be connected with the Radial1 node. Click-drag the input B of the Copy1 node to the Tranform1 node; a connection is established between the Copy1 and Transform1 nodes.

Step - 13
Make sure the Copy1 node is selected in the Node Graph panel and then press 1 to view the output in the Viewer1 panel.

Step - 14
Make sure the Copy1 node is selected in the Node Graph panel and then connect a Premult node to it from the Merge menu; the Premult1 node will added to the Node Graph panel.

You will notice in the Viewer1 panel that we the output is exactly same as that of the Multiply node. Figure 4 shows the node network in the Node Graph panel.
Figure tu5-4 The node network in the Node Graph panel
Figure 4 The node network in the Node Graph panel
Next, you will learn the workflow while color-correcting a premultiplied image.

Step - 15
Choose File > New from the menu bar to create a new script.

Step - 16
Load the jet.jpg image in the script; the Read1 node will be inserted in the Node Graph panel.

Step - 17
Add a Checkerboad node to the Node Graph panel; the Checkerboard1 node will be inserted in the Node Graph panel.

Step - 18
Select the Read1 node in the Node Graph panel and then press M; the Merge1 node will be inserted in the Node Graph panel.

Step - 19
Click-drag the input B of the Merge1 node and then drag the cursor to the Checkerboard1 node; a connection is established between the Merge1 and Checkerboard1 nodes.

Step - 20
Select the Merge1 node in the Node Graph panel and then press 1 to view the output of the Merge1 node in the Viewer1 panel, as shown in Figure 5.
Figure tu5-5  The output of the Merge1 node
Figure 5  The output of the Merge1 node

Step - 21
Select the Read1 node in the Node Graph panel and then insert an Add node between Read1 and Merge1 nodes.

Step - 22
In the Add tab of the Add1 node properties panel, select rgb from the channels drop-down and then specify a color value for the value parameter. You will notice that the adjustment is affecting whole image, refer to Figure 6. To overcome this, you need to first unpremultiply the result of the Read1 node and then premultily the output of the Add1 node.
Figure tu5-6  The affect of color correction
Figure 6  The affect of color correction
Step - 23
Select the Read1 node in the Node Graph panel and then insert a Unpremult1 node between the Read1 and Add1 nodes.

Step - 24
Insert a Premult1 node after Add1 node. Now, make color adjustments using the Add1 node. You will notice that the color-correction is now applied to the jet properly. Figure 7 shows the node network.
Figure tu5-7  The node network in the Node Graph panel
Figure 7  The node network in the Node Graph panel



No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...