How to Output Z-Depth Pass in Blender Compositor

This guide provides a straightforward walkthrough on how to extract and export a Z-depth pass using Blender's compositor. A Z-depth pass contains distance data from the camera to the objects in the scene, which is essential for creating depth of field, fog effects, and compositing in external software. Below are the exact steps to enable, process, and save a depth map directly from Blender.

Step 1: Enable the Z-Pass

Before compositing, you must ensure Blender renders the depth data for your scene.

  1. Open the View Layer Properties tab in the Properties editor (the icon resembles stacked layers).
  2. Expand the Passes section and open the Data sub-panel.
  3. Check the box labeled Z (or Depth).

Step 2: Set Up the Compositor Workspace

  1. Switch to the Compositing workspace at the top of the interface.
  2. Check the Use Nodes box at the top header of the Compositor editor.
  3. You will see a Render Layers node connected to a Composite node. The Render Layers node will now display a Depth output socket.

Step 3: Normalize the Depth Information

Raw Z-depth data measures the exact distance in Blender units, which often results in values far greater than 1.0 (appearing completely white on standard image displays). You must remap these values depending on your target format.

  • For 8-bit or 16-bit Image Formats (PNG, JPEG, TIFF):
    1. Press Shift + A and search for the Map Range or Normalize node.
    2. Connect the Depth output of the Render Layers node to the input of the Map Range node.
    3. Set the From Min to your closest distance and From Max to your farthest visible distance, with To Min at 0.0 and To Max at 1.0. Alternatively, use the Normalize node for automatic scaling.
    4. Add an Invert Color node if you require near objects to be white and far objects to be black.
  • For 32-bit Multilayer OpenEXR Formats:
    • Do not normalize the data. OpenEXR preserves raw, floating-point distance values without clipping.

Step 4: Configure the File Output Node

To save the Z-depth pass as a separate image file alongside your beauty render:

  1. Press Shift + A and add an Output > File Output node.
  2. In the Node Properties sidebar (press N), set the file format (such as OpenEXR, PNG, or TIFF).
  3. Connect your processed depth signal (from the Map Range/Normalize node) or raw depth signal (for OpenEXR) into the input socket of the File Output node.
  4. Set the destination directory in the File Output node settings.

Step 5: Render and Save

Press F12 to render the scene. Blender will process the composite tree and automatically write the Z-depth map to the directory specified in your File Output node.