How to test scene depth against custom depth in a post process material

I’m working on a game which involves a big “kill-sphere” and I want to do a custom-depth effect so that everything outside of the sphere is orange. I have partly achieved this but since custom depth doesn’t test against scene depth, the sphere appears to be visible through the floor. Hopefully the pictures better demonstrates this.

Having only one custom depth, you can only test if scene is behind the sphere, or in front of it, but not both at the same time. Consider using sphere mask material expression and supply sphere position and radius externally.

1 Like