Scene Depth Node | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Scene Depth Node

    Description

    Provides access to the current Camera's depth buffer using input UV, which is expected to be normalized screen coordinates.

    Note: Depth buffer access requires depth buffer to be enabled on the active Render Pipeline. This process is different per Render Pipeline. It is recommended you read the documentation of your active Render Pipeline for information on enabling the depth buffer. If the depth buffer is unavailable this Node will return mid grey.

    Note: The executed HLSL code for this Node is defined per Render Pipeline, and different Render Pipelines may produce different results. Custom Render Pipelines that wish to support this Node will also need to explicitly define the behaviour for it. If undefined this Node will return 1 (white).

    NOTE: This Node can only be used in the Fragment Shader Stage.

    Unity Pipelines Supported

    • HD Render Pipeline
    • Lightweight Render Pipeline

    Ports

    Name Direction Type Binding Description
    UV Input Vector 4 Screen Position Normalized screen coordinates
    Out Output Vector 1 None Output value

    Depth Sampling modes

    Name Description
    Linear01 Linear depth value between 0 and 1
    Raw Raw depth value
    Eye Depth converted to eye space units

    Generated Code Example

    The following example code represents one possible outcome of this node.

    void Unity_SceneDepth_Raw_float(float4 UV, out float Out)
    {
        Out = SHADERGRAPH_SAMPLE_SCENE_DEPTH(UV);
    }
    
    In This Article
    • Description
    • Ports
    • Depth Sampling modes
    • Generated Code Example
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023