Why is this post process material drawing over top of objects placed well after the game starts?

Here’s my setup:

  • Only grass has “Render Custom Depth = True”
  • Only grass has “SetCustomDepthStencil = 1”
  • Post process volume has material added
  • PPV bounds are full level
  • I’m comparing scene depth vs custom depth
  • I added extra filtering on depth stencil to ensure its only drawing to grass

Problem: After my game starts and the post process shader draws the grid if i place down a building it draws the grid over top of my objects. If you look its not that the shader is being rendered beyond the object. its being perfectly printed along the geometry. Why is this happening? What am i missing?

here is my material setup.

Thanks in advance!

Bump. I’ve been slamming my head into this for an entire day haha

Why are you dividing your custom depth by 10000?

I would guess that’s the source of your problem. The depth units need to be the same scale, and you’re rescaling them in a way that makes it unlikely for SceneDepth to ever be smaller than Custom Depth, so it will just always return A<B

If that doesn’t work you’re gonna need to explain the rest of this graph. I’m honestly baffled by what the other two branches are supposed to be doing (some kind of distance clipping?)

@Arkiras
Thank you for taking a look at it. What you’re seeing is the result of hours of frustration and bad trial and error. I’ve since taken a break and started over. Of course I figured it out within 30 minutes. My newest problem however is that this Grid is printing over ALL grass and i need it to only print on the grass thats within the game board… i tried to setting Custom Stencil = 2 on the physical grid tiles and add it to the material as a second mask in the chain, but that didn’t seem to work.

Here’s my corrected code for future viewers of the thread:

Result:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.