UPDATE IN THE COMMENTS
Hey everybody. Im trying to do custom shadow sampling in my shader by getting a raw depth shadow map from a directional light as shown in the SetShadowSamplingMode example here (Unity - Scripting API: Rendering.CommandBuffer.SetShadowSamplingMode) and everything works fine with scene game objects. However i have a custom terrain thats is rendered through Graphics.DrawMesh, and it appears to be wrong on the shadowmap. Heres the screenshot of the problem:
As you can see, the sphere and the orange car both cast correct shadows (they are scene gameobjects). But shadows from terrain are completely wrong, all patchy and gradienty. Am i doing something wrong? Is this an normal behaviour? What can i do to make it output proper depth?
This is how i sample shadow in the shader btw, if its important:
half3 shadCoords = mul(unity_WorldToShadow[0], float4(i.wpos, 1)).xyz;
float shad = UNITY_SAMPLE_SHADOW(_MyShadowMap, shadCoords);