Z Depth AOV

Beauty render composited with Z Depth AOV (rollover image).

 

In this short tutorial, we will cover the process of setting up and rendering out a 'Z' depth AOV which can then be composited with the beauty render in Nuke to achieve a realistic depth of field effect. The 'Z' depth AOV contains the depth information of the shading points.

  • Render the scene and open the EXR file in Nuke. 

If you open your multilayer EXR in Photoshop it must be done in 32-bit as converting it to 8-bit will lose all of the depth info. The Z depth image is unclamped, so it may appear pure white. Go to Image -> Adjustments -> Exposure and adjust the exposure until you get something that looks like a regular z-depth pass.

When viewing the depth AOV in Nuke, it might only show red. The Depth channel will give you non-antialiased, non-normalized depth data in the alpha channel. Non-normalized means that the Z depth values are not between 0 and 1 (distance in front of the camera), so you must divide the Z values by the far clipping plane value to get 0..1 values. This remapping is only required when viewing the depth channel in the viewer. It is not needed to make the zdefocus node work.

Z depth channel viewed within Nuke

 

  • Connect a 'Zblur' ('ZDefocus' in Nuke 7) to the EXR render and enable 'focal-plane setup'. The default setting of the Zblur node should work. Z should be set to 'depth.z' and 'math' should be set to 'depth' (the Z value in the depth channel is the distance in front of the camera).
  • Adjust the 'focus plane' until the green area is where you want the area of focus to be. The red color shows the area that has less depth of field. The blue color represents the area that falls outside the depth of field area. The green color represents the area that is inside the area of depth of field. If the depth parameter is set to 0, you will not be able to see any green. 

Focal-plane setup enabled (green area is in focus)

 

  • Once you are happy with the 'focus plane', disable 'focal-plane setup'. Increase the 'depth-of-field' to one. You should now see the RGB image being blurred by the 'Zblur' node.

 

That concludes this short tutorial. The benefits of using a Z Depth AOV are obviously speed and flexibility. Being able to make changes to the depth of field in the compositor in real time is a big advantage. Rendering with true depth of field, while looking better in most cases, can require a large number of AA samples to resolve issues with noise. Below is a comparison between rendering true depth of field and rendering the scene without DOF (using a composited 'Z' depth AOV). Even with 8 Camera (AA) samples, there is still some noise in the heavy depth of field areas of the image rendered with true depth of field. In this case, the render with true DOF took about twice as long to render as the image using a Z Depth AOV.

  

Limitations

There are limitations to using a 'Z' depth AOV. For example, it is not possible to focus on an object reflected in a mirror (see below):

Focusing on an object in a mirror is not possible using a 2d 'Z' depth AOV (above image rendered with true depth of field).





3d scan model courtesy of Ten24.

  • No labels