Unity's URP shadow shader example gives sharp shadows only

I am trying to get shadows working in Unity 6 using custom shading. Unity supplies the following shader example:

I do not get soft shadows when using the example code.

I have reviewed the Shadows.hlsl code and checked if the MainLightRealtimeShadow() is early-ing out but that is not the issue. It seems to me that the shadow parameters are not set somehow.


Try adding #pragma multi_compile_fragment _ _SHADOWS_SOFT under the other #pragma lines

Thanks, but I already have that pragma.

#if defined(SHADERGRAPH_PREVIEW)
#else
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
#pragma multi_compile _ _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHTS
#pragma multi_compile_fragment _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile_fragment _ _SHADOWS_SOFT
#pragma multi_compile _ SHADOWS_SHADOWMASK
#pragma multi_compile_fragment _ _SCREEN_SPACE_OCCLUSION
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ LIGHTMAP_SHADOW_MIXING
#endif

Hey man, hope you figured it out, but if not, I had this problem myself for a while, and I solved it by inspecting Unity’s Lit shader. What they do is use all the pragmas, so try adding the following:

#pragma multi_compile_fragment _SHADOWS_SOFT _SHADOWS_SOFT_LOW _SHADOWS_SOFT_MEDIUM _SHADOWS_SOFT_HIGH

It solved the issue for me, so hope it works for you too!

1 Like

That solved it for me thanks!
Unity should update their example.

1 Like