- Home /
Render material only when in front of specific objects
Hi,
I am doing a side view game with some level destruction and I would like to add scorched ground decals that only render if there is some piece of set behind the decal. So for example, I spawn a decal over some props (side view) and it only renders on these, not on the background or on characters, and when I destroy more of the set, this decal adapts and doesn't get displayed where things are now destroyed.
Here is a conceptual illustration of what I'm trying to explain, with the set in white, the decal in yellow and the background in black:
From the research I did i'm assuming some shaders should be able to sense the depth and only display the decal if there is something behind, but I'm unfortunately not versed in shaders at all. This would also solve only part of the problem as I don't want decals to render on characters, only over the set pieces (which can go on their own layers / have their own tags if need be).
Thanks in advance for your help!
Your answer
![](https://koobas.hobune.stream/wayback/20220612054736im_/https://answers.unity.com/themes/thub/images/avi.jpg)