Search Unity

Question How to always render an object below other objects regardless of position.

Discussion in 'High Definition Render Pipeline' started by xytor500, Feb 28, 2023.

  1. xytor500

    xytor500

    Joined:
    Mar 29, 2017
    Posts:
    73
    Hi,
    I have a set of objects that need to be rendered "below" all other objects, regardless of their position.

    I know the two-camera trick for getting objects to render on top of other objects, but I'm not sure how to adapt it to always render the object below.
     
  2. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    769
    Hi, I think the simplest way is to create a shader graph and set the ZTest to "Greater" or "GEqual".
     
  3. xytor500

    xytor500

    Joined:
    Mar 29, 2017
    Posts:
    73
    Is this the same thing as Depth Test in the shader graph? Setting that to Greater or Greater Equal just makes the objects invisible. Maybe it's incompatible with transparency?
     
  4. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    769
    It'd be better if there's a screenshot showing what you'd like to achieve. Does the "below" mean behind other objects?
     
  5. wwWwwwW1

    wwWwwwW1

    Joined:
    Oct 31, 2021
    Posts:
    769
    After checking the title, I think you can search for stencil test (can be found in Shader Graph) instead of Z (depth) test. I haven't tried anything using stencil, so sorry that I cannot provide much help about this.
     
    olavrv likes this.