Wednesday, May 29, 2013

Working with the ZDefocus node in Nuke 7 Part - 1

The ZDefocus node is a major upgrade to the ZBlur node. The ZDefous node is used to blur an image according to the depth map channel and gives you ability to simulate blur using depth of field. This node splits the input image into layers. All pixels have the same depth value within a layer. Also, the whole layer receives same amount of blur size. After processing all the layers present in the input image, the ZDefocus blends layers together from back to the font of the image thus preserving the order of the elements in the scene.

To add a ZDefocus node to the Node Graph panel, select the input image that you need to blur and then choose the Filter button to display the Filter menu. Next, choose ZDefocus from the menu; the ZDefocus# node will be inserted in the Node Graph panel. Also, The ZDefocus# node properties panel will be displayed with the ZDefocus tab chosen in the Properties Bin, refer to Figure 1.
art21-1
Figure 1
You notice in the Node Graph panel that the apart from the regular mask and Output connectors, the ZDefocus# node has two more input connectors: filter and image. These are discussed next:

filter: This image connected to this input takes the shape of the out of focus highlights. These highlights are also referred to as “Bokeh”. You can use a Roto or Flare node to create the filter image. If you want to add color fringing to Bokeh, you can use also connect a color image to the filter input.

image: This input is used to connect to to the input image that you want to blur. Make sure that this image contains a depth channel.

You will also notice a focal point widget in the Viewer# panel. This widget is used to adjust the position of the focal plane. On moving this widget, the focus plane and focal point parameters update automatically. If you select the Use GPU if available check box in the node properties panel, the processing of the node is run on the GPU instead of CPU. If GPU is present in the scene, its name will be displayed above the check box, refer to Figure art21-1. You can also select which GPU you need to use. To do so, open the Preferences dialog box by pressing SHIFT+S and then choose the desired option from the GPU Device drop-down of the GPU Device area, refer to Figure 2.
art21-2
Figure 2
Before moving farther, navigate to http://www.mediafire.com/download/lpbg7sv7lf7hlz2/art021.zip and download the zip file. Next, extract the contents of the zip file to your hard drive. The zip file contains the chopper.exr file which we will used to explain the concepts here.

Step – 1
Lunch Nuke and start a new script in it.

Step – 2
Load the chopper.exr file into the script; the Read1 node will be inserted in the Node Graph panel.

Step – 3
Make sure the Read1 node is selected and then press 1 to view its output in the Viewer1 panel, refer to Figure 3.

Step – 4
Select Z_Depth from the Channel Sets drop-down; the depth channel will be displayed in the Viewer1 panel, refer to Figure 4. Now, select rgba from the Channel Sets drop-down.
art21-3
Figure 3
art21-4
Figure 4
Step – 5
Connect a ZDefocus node to the Read1 node. You will notice an error message in the Viewer1 panel about the missing depth channel. This error is generated because by default the ZDefocus node looks for depth information in the depth.z channel which is selected by default in the depth channel drop-down.

Step – 6
Select Z_Depth.red from the depth channel drop-down; you will notice blur in the Viewer1 panel, refer to Figure 5.

The options in the channels drop-down located above the depth channel drop-down are used to select channels on which the blur will be applied.

Step – 7
In the Viewer1 panel, move the focal point widget to the front part of the chopper; the area around the point will be in focus immediately, refer to Figure 6.
art21-5
Figure 5
art21-6
Figure 6
Step – 8
Select depth from the math drop-down.

The options in math drop-down are used to specify the method that will be used to calculate the distance between the camera and the object using the information available in the depth channel. If you hove the mouse pointer over the math drop-down, a tooltip will appear with information about the formula used to calculate the blur. By default, the far=0 option is selected in this drop-down. This option is compatible with the depth maps generated using Nuke and RenderMan.

Step – 9
Enter 0.1, 8, and 10 in the depth of field, size, and maximum fields, respectively.

The depth of field parameter is used to specify the depth of field around the focus plane. The size parameter is used to set the size of the blur. The size of the blur is clipped at the value specified using the maximum parameter. The blur inside check box located next to the depth of field parameter is used to apply a small amount to the in focus area so that the transition between the in focus and out of focus areas look smooth.

Step – 10
Select the focal plane setup from the output drop-down; the depth of field information will be displayed in the rgb channels in the Viewer1 panel. Move the focal point to see the output properly, refer to Figure 7.

The red color represents the area (less than DOF) that is in focus. The green color represents the area that is inside DOF. If depth of parameter is set to 0, you wont be able to see green area in the viewport. The blue color represents the area that is greater than DOF.

Step – 11
Select the layer setup option from the output drop-down.

This option is similar to the focal plane setup option but it displays the DOF information after the depth is divided into layers, refer to Figure 8. When the automatic layer spacing check box is selected, the ZDefocus node automatically decides how many depth layers to be used based on the value specified by the maximum parameter. When you clear this check box, you can use the depth layers and layer curve parameters to control the numbers of layers and spacing between the layers, respectively.
art21-7
Figure 7
art21-8
Figure 8
Now, experiment with the controls in the ZDefous1 node properties panel until you get the desired result. Also, use the focal point widget in the Viewer1 panel to interactively change the focus point.

This concludes the part – 1.

Read Part - 2 here.

6 comments:

  1. This is great for elements in a scene that can come with a Z.
    The REAL beauty of nuke is that you can make a Z from ANY ELEMENT.

    Make a tute that covers real problems in Compositing.
    Explore DEEP.

    Experience is the key. Don't say what can be read in the manual.
    Make it real world comping.

    ReplyDelete
    Replies
    1. You are right Simon.

      This blog serves as an additional learning resource for the Nuke Book and with books there are some limitations. There is a limit on no of pages on a paperback edition. So, initially there will be some basic tutorials that we could not add to the book. It will take some time but we will definitely add some tutorials on real world comping.

      Thanks.

      Delete
  2. Hi,

    Can someone help me figure this out:
    http://www.mediafire.com/download/a74jmtypbwpb43a/nuke_chopperexr.jpg

    I connected both the filter and image to the Read node and it shows the Zdepth in the viewer, but I must be doing something very wrong as adjusting values doesn't do anything and I'm not seeing an rgb output in the viewer?

    ReplyDelete
    Replies
    1. Hi Amir,

      Look at the top left corner of the Viewer1 panel, you have selected Z_Depth in the Channel Sets drop-down. As a result, the depth information is displayed in the Viewer. You need to select the rgba option from the Channel Sets drop-down to see the result of the ZDefocus node.

      I hope it will resolve your problem.

      Cheers !!

      Delete

Related Posts Plugin for WordPress, Blogger...