The ZDepth Render Element is a grayscale image that renders each pixel based on its distance from the camera in the view.
The ZDepth Render Element provides information about each object's distance from the camera in the current view. Each pixel representing the object is evaluated for distance individually; different pixels for the same object can have different grayscale values. In this render element, objects (or portions of objects) closest to the camera appear as white while those furthest away appear black. Objects between the furthest and nearest points are rendered in varying shades of gray. The lighter the gray, the closer an object pixel is to the camera.
The most common usage of the ZDepth Render Element is as a control for depth of field in the composite. Depth of field can be challenging to do correctly, requiring many tweaks and re-renders; using the ZDepth Render Element in a composite is usually much faster, and allows easier and faster adjustment than trying to get it exactly right within the render.
UI Path: ||Toolbar|| > V-Ray Menu icon > Render > VRayRenderElement > Type: ZDepth
Use depth from the camera – Specifies whether to use to camera clip boundaries as the minimum and maximum ZDepth distance. Enabling this option disables the Depth Black and Depth White parameters.
Depth Black – Objects further than this distance from the camera will render as black. This option is available only when Use depth from the camera is disabled.
Depth White – Objects up to this distance from the camera will render as white. This option is available only when Use depth from the camera is disabled.
Depth Clamp – Clamps the ZDepth colors to a linear 0-1 range.
The Z-Depth Render Element parameters for minimum and maximum depth, Depth Black and Depth White, can be set to various values to provide different ranges of depth in the render element. In these examples, Depth Clamp is enabled.
Black = 0, White = 8000
Black = 400, White = 8000
Black = 0, White = 4000
Black = 0, White = 2000
Use depth from the camera = enabled
The Z-Depth Render Element is useful for adding depth of field to the final image in post production within a compositing application without the need for re-rendering. It can also be used to create basic fog by overlaying it on the composite in Add mode or Screen mode, with color correction as needed.
Note: In the example below the depth of field effect has been exagerated for the purposes of clarity.
ZDepth Render Element (depth from camera)
Original Beauty Composite with no depth of field added in composite
Depth of Field applied to composite using ZDepth pass