Upgrade from 2020.3.17f1 -> 2021.2.4f1 makes shadows disappear (URP)

Hi,

if I upgrade my project from 2020.3 => 2021.2 the shadows of a specific shader of mine go missing and I can’t figure out why.

The project is literally just upgraded, I didn’t change anything else (and can reproduce it that way). I can’t figure out what is going on, so any help is deeply appreciated. The shader itself is a shader that I use within the UI to have a transparent layer that can receive shadows (and thus I simulate 3D object shadows within a normal UI canvas).

This is the shader code:

Shader "Transparent Shadow Receiver"
{
    Properties
    {
        _ShadowColor ("Shadow Color", Color) = (0.35,0.4,0.45,1.0)
    }
    SubShader
    {
        Tags
        {
            "RenderPipeline"="UniversalPipeline"
            "RenderType"="Transparent"
            "Queue"="Transparent-1"
        }
        Pass
        {
            Name "ForwardLit"
            Tags { "LightMode" = "UniversalForward" }
            Blend DstColor Zero, Zero One
            Cull Back
            ZTest LEqual
            ZWrite Off
 
            HLSLPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma prefer_hlslcc gles
            #pragma exclude_renderers d3d11_9x
            #pragma target 2.0
            #pragma multi_compile _ _MAIN_LIGHT_SHADOWS
            #pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE
            #pragma multi_compile _ _SHADOWS_SOFT
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"
            CBUFFER_START(UnityPerMaterial)
            float4 _ShadowColor;
            CBUFFER_END
            struct Attributes
            {
                float4 positionOS : POSITION;
            };
            struct Varyings
            {
                float4 positionCS               : SV_POSITION;
                float3 positionWS               : TEXCOORD0;
            };
            Varyings vert (Attributes input)
            {
                Varyings output;
                VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
                output.positionCS = vertexInput.positionCS;
                output.positionWS = vertexInput.positionWS;
                return output;
            }
            half4 frag (Varyings input) : SV_Target
            {
                half4 color = half4(1,1,1,1);
            #ifdef _MAIN_LIGHT_SHADOWS
                VertexPositionInputs vertexInput = (VertexPositionInputs)0;
                vertexInput.positionWS = input.positionWS;
                float4 shadowCoord = GetShadowCoord(vertexInput);
                half shadowAttenutation = MainLightRealtimeShadow(shadowCoord);
                color = lerp(half4(1,1,1,1), _ShadowColor, (1.0 - shadowAttenutation) * _ShadowColor.a);
            // #else
            //     color = half4(1,0,0,0.2);  
            #endif
                return color;
            }
            ENDHLSL
        }
    }
}

Does anyone have an idea?

Edit: to have that rendered besides the shader I use the following render object in the forward renderer:

in 12x they changed a few of your pragma
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS_CASCADE

this is now combined into one line
#pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN

better you open the source unity shader and look over for other changes also
you also be missing other features just added in 12x

1 Like

Ok, that didn’t do the trick, but by playing around a bit I figured out that
_MAIN_LIGHT_SHADOWS
isn’t defined anymore after the upgrade?
After changing line 57 to
#if defined(_MAIN_LIGHT_SHADOWS) || defined(_MAIN_LIGHT_SHADOWS_CASCADE) || defined(_MAIN_LIGHT_SHADOWS_SCREEN)

it works again…

1 Like

correct its also as a few that are no longer applicable

Is that documented somewhere in some kind of changelog or something? I was searching for that but couldn’t find anything like it…

https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@12.0/changelog/CHANGELOG.html

Right here. You can change the version in the top left

Only it’s not there in the changelog… Thanks for the info in this thread!