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!