UnityURPUnlitScreenSpaceDecalShader icon indicating copy to clipboard operation
UnityURPUnlitScreenSpaceDecalShader copied to clipboard

Layer-Specific Decals

Open wes-hawkins opened this issue 4 years ago • 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!

wes-hawkins avatar Sep 22 '20 04:09 wes-hawkins

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

dsazulay avatar Sep 22 '20 20:09 dsazulay

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

ColinLeung-NiloCat avatar Sep 23 '20 14:09 ColinLeung-NiloCat

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

HigginDazs avatar Oct 01 '20 10:10 HigginDazs

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.

ColinLeung-NiloCat avatar Jan 02 '21 07:01 ColinLeung-NiloCat