Directional lights can’t cast shadows onto Standard Surface Shaders, only inside VRchat
RavenWorks
VRChat Version: 1054
Description of the bug: When creating a world, if you use a Standard Surface Shader, and cast a shadow onto it with a directional light, the shadow will pass through it, even though it works fine in standalone builds from the same version of Unity.
Steps to reproduce (how did you encounter the bug?):
- Create a new VRChat world in Unity.
- Create a realtime directional light which casts shadows.
- Create a new Standard Surface Shader (no need to change it at all)
- Create a material that uses that new shader
- Create a 3D object in the scene, and put that material on it
- Create another 3D object in the scene, and leave it with the default material, and position it so that it casts a shadow ONTO the previous object
- "Build & Test" into VRchat.
- Observe that there is NO visible shadow.
A more detailed example scene is suggested here: https://ask.vrchat.com/t/directional-lights-cant-cast-shadows-onto-standard-surface-shaders-only-inside-vrchat/5168 which demonstrates things like, point light shadows work fine, and if there's another surface behind, the shadow will seem to pass THROUGH the custom shader
Any extra files? (output logs, screenshots): There are several screenshots in the thread, but I've attached a copy of how it looks in a standalone build (correct) and how it looks in VRchat
Log In
Faxmashine
I often see this affecting world and avatar creators. It's a difficult issue to diagnose, so it would be great if we could get a workaround like RavenWorks's into the SDK.
RavenWorks
Good news, I've found a very simple workaround; if you change the surface shader's first pragma line from
#pragma surface surf Standard fullforwardshadows
to
#pragma surface surf Standard fullforwardshadows addshadow
then it will behave in VRchat the same way that it does everywhere else.
I think I'd totally accept just adding that note to the documentation somewhere; it's completely not obvious, but at least it's simple to do once you know it.