Changing the Rendering Order using Depth Texture

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

You may use the “Render Objects” renderer feature to draw objects in different queues, using different ZTest options:
https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@10.5/manual/urp-renderer-feature.html

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 :slight_smile:

1 Like