Sunday, June 2, 2013

How to create a position pass in Nuke 7 using the DepthToPosition node

The DepthToPosition node is used to generate 2D position pass using the depth data available in the input image. The position pass is created by projecting the depth through camera. Then, position of each projected point is saved. This node along with the PositionToPoints node is used to create a point cloud similar to the point cloud that the DepthToPoints node generates. In fact, the DepthToPoints node is a gizmo that contains the DepthToPosition and DepthToPoints nodes. In this tutorial, we will generate a position pass and then place a 3D sphere in the scene. To do this, follow these steps.

Step - 1
Navigate to the following link and then download the zip file to your hard-drive: https://www.dropbox.com/s/xo7eemr6qz16icl/nt007.zip. Next, extract the content of the zip file.

Step - 2
Using a Read node, bring in the nt007.rar; the Read1 node will be inserted in the Node Graph panel.

Step - 3
Connect the Read1 node to the Viewer1 node by selecting the Read1 node and then pressing 1, refer to Figure 1.


Figure 1
Step - 4
Add a DepthToPosition node from the 3D menu; the DepthToPosition1 node will be inserted in the Node Graph panel.

You will notice that there is no output in the Viewer1 panel because we need to provide the correct depth channel by selecting appropriate channel from the depth drop-down in the DepthToPosition tab of the DepthToPosition1 node properties panel. The depth information in the nt007.exr file contained in the Z_Depth channel.

Step - 5
Select the Z_Depth.red option from the depth drop-down; the position pass will be displayed in the Viewer1 panel, refer to Figure 2.
Figure 2
Step - 6
Add a Camera node from the 3D menu. Next, import the Camera001.chan file that you have downloaded earlier.

Step - 7
Connect the camera input of the DepthToPosition1 node to the Camera1 node.

If you need to change the output channel, you can select the channel from the output drop-down available in the DepthToPosition tab of the DepthToPosition1 node properties panel. You can also create a new Channel Set for the position pass.

Next, you will place a 3D sphere on top of the first chopper.

Step - 8
Sample pixels from the Viewer1 panel and then note down the coordinates, refer to Figure 3.
Figure 3
Step - 9
Add a Sphere node from the 3D > Geometry menu. Next, add a ColorBars node from the Image menu.

Step - 10
Connect the ColorBars1 node to the Sphere1 node.

Step - 11
In the Sphere tab of the Sphere1 node properties panel, enter the XYZ coordinates values that you have noted down in step 8 in the x, y, and z fields corresponding to the translate parameter.

Step - 12
Connect a ScanlineRender node to the Sphere1 node. Make sure the ScanlineRender1 node is selected in the Node Graph panel and then press 1 to view its output in the Viewer1 panel.

Step - 13
Select the ScanlineRender1 node and then press M; the A input of the Merge1 node is connected with the ScanlineRender1 node.

Step - 14
Connect the B input of the Merge1 node with the Read1 node.

You will notice there is no sphere on top of the chopper. To rectify this, we need to connect the same camera to the cam input of the ScanlineRender1 node that we have used to generate the position pass.

Step - 15
Connect the cam input of the ScanlineRender1 node with the Camera1 node; the sphere will be visible in the Viewer1 panel, refer to Figure 4.
Figure 4
Figure 5 shows the node network.
Figure 5

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...