For a 3rd person game, I’ve put in a script which makes objects between the camera and player mostly transparent so they don’t block the view. To keep the interiors of buildings from suddenly having sunshine coming in when the roof or walls are made transparent, I’m using a surface shader which (nominally) still blocks light even when at full transparency; but it only blocks light if the fallback is set to “VertexLit” rather than “Alpha/Diffuse”. That makes no sense, unless it either A) is falling back to these shaders rather than running mine, which also makes no sense; or B) maybe the surface shader is doing something differently underneath the hood depending on the fallback shader. Does anyone know what’s going on? I need it to work consistently on other machines, so I need to know what’s going on.
Shadows are done by a shadow caster pass. The shadow caster pass for the vertex lit shader is always opaque regardless of the alpha value. By default a surface shader doesn’t have its own shadow caster pass and is going to use the vertex lit shader’s shadow caster pass, but if you set it to use alpha/diffuse as the fallback it’ll use that shader’s shadow caster pass. Alternately if you use the addshadow option it’ll construct a shadow caster pass using your surface shader function rather than using a generic one.
Thank you. Is this documented anywhere?
Probably not.
I added “#pragma addshadow” but that didn’t work.
The addshadow goes in the #pragma surface line, not by itself. Even then with a transparent shader I don’t know if it’ll cast a shadow since transparent shaders don’t generally cast shadows. Using Fallback “VertexLit” really is the correct solution.
See this page for information on addshadow.
See this page for information on adding a shadow caster pass using a vertex / fragment shader.