ColinLeung-NiloCat/UnityURPUnlitScreenSpaceDecalShader

Layer-Specific Decals

wes-hawkins opened this issue · 4 comments

Colin, this shader is fantastic, thank you! Would you be able to modify it to only project onto certain layers? That would make it absolutely perfect for just bout every possible need. I will happily pay a bounty for the layer-specific rendering!

You can use stencil to limit where the projection will appear.

you can use stencil or render queue, because it is a screen space method, it can't control where the decal will render.

Do you have an example showing this? I can't seem to get the decal to ignore specific layers

In you custom shader, you write a stencil value K first, usually your character shader.
https://docs.unity3d.com/Manual/SL-Stencil.html

Then, in the decal material, you set Stencil = only pass if stencil buffer's value NotEqual K

Since it is a screen space method, unity's Layer system is not useful, you need to rely on RenderQueue or Stencil.