Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Question Changing the Rendering Order using Depth Texture

Discussion in 'General Graphics' started by nomadshiba, Aug 31, 2022.

  1. nomadshiba

    nomadshiba

    Joined:
    Jun 22, 2015
    Posts:
    27
    So I have 3 main layers in my project.
    I need to render them with the order of:
    - Layer 2
    - Layer 1
    - Layer 0

    *Layer 0 is at top*

    I don't wanna use multiple cameras because it eats up the frame rate.
    So I thought maybe some how idk how, I can write to depth texture,
    and for example fit stuff in:
    Layer 2 between 1.0 and 0.9,
    Layer 1 between 0.9 and 0.7
    Layer 0 between 0.7 and 0.0, in the depth texture
    So they render in the correct order, but idk how to do that with URP

    or idk if there is another way without using multiple cameras or camera stacking
     
  2. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,670
  3. nomadshiba

    nomadshiba

    Joined:
    Jun 22, 2015
    Posts:
    27
    Used Render Objects, I was able to fix it using Stencil Buffer, it took me a while to figure out how it works and what it does. But it seems like it works now :)