Skip to main content

Depth Render Texture

Depth Render Texture enables the retrieval of a camera’s depth stencil buffer, allowing users to obtain depth cache information from the current scene. This information helps create depth-based interactions, such as collision detection and depth-dependent visual effects. The darker the rendered depth color, the closer the object is to the camera.

depth render texture demo

How Depth Render Texture Works

The following are key points for the integration of Depth Render Texture:

  • Depth Render Texture: allows capturing depth information within the scene from a 3D camera
  • Depth information is represented in grayscale:
    • Darker areas indicate objects that are closer to the camera
    • Lighter areas indicate objects that are farther from the camera
  • Enables the creation of depth-based special effects and gameplay mechanics

Depth Render Texture Usage

  • Depth Render Texture can be used in the Camera component to display depth visuals

  • It can be applied as a texture in a material graph and visual effects graph

    apply depth render texture
  • Can be dragged into the Visual Scripting panel for advanced interactions

Depth Texture vs. Depth Render Texture

  • Depth Render Texture: Captures real-time depth data from the camera and renders it as a texture, Provides real-time depth relations in a scene, offering more dynamic interactions
  • Depth Texture: Uses a precomputed depth detection algorithm to estimate object depth

Add Depth Render Texture

To add Depth Render Texture:

  1. Go to the Assets Panel
  2. Click the Add button [+]
  3. Go to Texture
  4. Select Depth Render Texture

The texture appears in the Render Textures folder of the Assets panel.

depth render texture in assets panel

Apply Depth Render Texture to an Object

  1. Select an object with a Camera component in the Hierarchy panel

  2. Locate the Camera component in the Inspector panel

  3. Click the Depth Render Texture field

    depth render texture property
  4. Select an available Depth Render Texture asset in the asset picker

    asset picker

The camera will now output depth information as a grayscale texture.