@Devil_Inside can you try using the “UNITY_SHADOW_COORDS” / “UNITY_TRANSFER_SHADOW” / “UNITY_SHADOW_ATTENUATION” instead of the older macros without “UNITY_” prefix?
UNITY_SHADOW_ATTENUATION and UNITY_TRANSFER_SHADOW require a different set of parameters than their “non UNITY” counterpart. I can’t find any documentation on these macros.
What else should I pass to these macros?
#define UNITY_TRANSFER_SHADOW(a, coord)
“a” is the name of your v2f parameter, “coord” is lightmap UV channel in app2v. No lightmap - put any UV from the app in there. #define UNITY_SHADOW_ATTENUATION(a, worldPos)
“a” is the name of your v2f parameter, worldPos is the fragment’s position in world space.
That worked!
Thanks!
I think a good idea would be to update the documentation here: https://docs.unity3d.com/Manual/SL-VertexFragmentShaderExamples.html
and also the Mobile-VertexLit-OnlyDirectionalLights shader that comes built-in with Unity and is affected by this issue.
Just tested the new macros in a build and unfortunately one scene, that had very small shadow distance, was glitching, and all the other scenes had slightly worse performance than my previous method.
The method that I was using as a workaround previously is a lerp to cut off any shadows past certain distance:
I got bitten by this today but shadows still seem to not work with these functions for me. I tried to create a minimal shader that implements this, is it correct?
I’m having a hard time implementing this with a mixed lighting setup. If I have an object with a vert/frag shader that uses the UNITY_SHADOW_ATTENUATION and has baked lightmap with shadowmask, the behaviour is odd. Up close, it looks correct, but as I get farther away and approach the shadow distance (set in Quality settings), the object becomes dark (shadow_attenuation becomes 0). But once I go far away enough, the object becomes bright again (shadow_attenuation becomes 1)