docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Position (Depth)

    Menu Path : Operator > Sampling > Position (Depth)

    The Position (Depth) Operator samples the depth-buffer of a Camera and retrieves the position in world space. You can use this depth information to project particles into the scene.

    Operator settings

    Setting Type Description
    Camera Enum Specifies which Camera to sample the depth of. The options are:
    • Main: Uses the first Camera in the scene with the MainCamera tag.
    • Custom: Uses the Camera you specify in the Camera port.
    Mode Enum Specifies the method this Operator uses to sample the depth-buffer. The options are:
    • Random: Uses a random UV value between 0 and 1 to sample the depth-buffer.
    • Sequential: Selects UVs based on the ParticleID attribute and the value of the Grid Step property. This samples positions sequentially every Grid Step number of pixels.
    • Custom: Allows you to specify UVs manually with the UV Spawn property.
    Cull Mode Enum Specifies a filter to apply to a sampled position. If you use a filter, the output property isAlive describes whether the sampled position is valid or not. The options are:
    • None: Does not use a filter.
    • Far Plane: If the sampled position is on the far plane, this option sets isAlive to false.
    • Range: Allows you to specify a Depth Range which determines whether a sampled position is valid or not. If the sampled position is outside the Depth Range, this option sets isAlive to false.
    Inherit Scene Color bool (Inspector) Specifies whether or not this Operator outputs the Camera's scene color information in addition to depth-buffer position/.

    Operator properties

    Property Type Description
    Camera Camera The Camera to use.
    This property only appears if you set Camera to Custom.
    Z Multiplier float A multiplier that offsets the sampled depth position. You can use this to avoid issues with z-fighting/overlapping when projecting particles into your scene.
    Grid Step uint The size of the grid this Operator uses to sample the depth buffer in pixels. This is based on the particleID and the Operator samples positions sequentially for every strip of pixels.
    This property only appears if you set Mode to Sequential.
    UV Spawn Vector2 The UV this Operator uses to manually sample the depth buffer.
    This property only appears if you set Mode to Custom.
    Depth Range Vector2 The valid depth range for the sampled position. If the sampled position is within this range, the isAlive property is true, otherwise it is false. This allows you to filter out sampled positions.
    This property only appears if you set Cull Mode to Range.

    Output properties

    Property Type Description
    Position Position The world-space position of the Camera's depth buffer sample.
    color Color The color of the Camera's scene color buffer sample.
    This property only appears if you enable Inherit Scene Color.
    isAlive bool Specifies whether the sampled position is valid with respect to the Cull Mode setting.
    • Far Plane: This is false when the sampled position is on the far plane and true otherwise.
    • Range: This is false when the sampled position is outside of the valid Depth Range and true otherwise.
    This property only appears if you set Cull Mode to Far Plane or Range.

    Limitations

    Currently, depth buffer sampling is only available in the High Definition Render Pipeline and does not work in the Universal Render Pipeline.


    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Operator settings
    • Operator properties
    • Output properties
    • Limitations
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)