I want to modify the “.FX/Glass/Stained…” shader from standard assets.
I am wondering how could I add a faint shadow casting to it?
I mean a faint shadow based on some color.alpha value.
I was hoping to use a shadow casting pass from standard shader, because it supports transparency.
I have added the color property, hoping to use alpha from it, and the UsePass "Standard/ShadowCaster" statement.
But this doesn’t seem to work that way.
The shadow caster pass from the standard shader is capable of doing semi-transparent shadows, but it requires specific keywords to be enabled on the material to make it work. By default the shadow is opaque and while you can force keywords on in the shader code using a #define, but those don’t seem to work when you use UsePass.
Instead you’ll want to look at the standard.shader file and copy the shadowcaster pass from there into your own file and add this near the top of the CGPROGRAM block for it: #define _ALPHABLEND_ON
It won’t be a lot of code, as most of the shadow caster shader code is in a separate file (which there’s going to be an #include for). As long as your custom shader uses the alpha of _MainTex and _Color to control the opacity of the shadow, it should “just work”.
Thanks.
I have just pasted the whole shadowcaster pass from standard shader.
Just replaced #pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON
with #define _ALPHABLEND_ON
and it works.