Stencil shader blocking shadows being drawn 'underneath'
I've made a stencil shader setup that only shows a part of a mesh that is inside a mesh, like a boolean effect. It works great, however, the masked out areas of the mesh still block the shadows of the other meshes from being drawn underneath.
This is the stencil section from the shader applied to the mesh that is being masked out:
Tags {
"Queue"="Geometry+2"
"RenderType"="Opaque"
}
Stencil {
Ref 2
WriteMask 252
Comp Equal
Fail DecrWrap
ZFail Replace
}
And this is the stencil section of the shader that is doing the masking (applied to a cylinder with inverted normals)
Tags {
"Queue"="Geometry+1"
"RenderType"="Opaque"
}
Stencil {
Ref 2
Pass Replace
}
And here's an image of the shadow being blocked:
I'm pretty new to this so any help that anyone can give would be really helpful, I can't work out my Unity seems to be discarding the shadow. I've also tried the obvious like making the material back culling, front culling and double sided - none of which helped.
Thanks!
Answer by floraffray · May 18, 2017 at 12:55 AM
Have you been able to figure this out? I am having a very similar issue with some shaders that are using the stencil buffer to create "sliced" geometry. Hopefully someone knowledgeable can chime in on this...
Answer by Gimlouis · Jul 19, 2017 at 08:03 AM
I have a similar problem, I am using stencil shaders to simulate the Hololens, and see holograms only through the lenses, but all shadows also disappear when I look through the lenses
I hpe someone has the solutions for this...