Artifacts on shadow cascade split with custom URP shader

Unity 6000.0.32f1 with Metal (Macbook M2)

I’m writing custom lit shader using URP.
I created .shader file (Create → Shader → Unlit Shader).
With documentation, I’ve managed to get working Lit shader, but the strange artifact occurs, based on camera distance to object.
I found out that the artifact happen when object is on shadow cascade split border. Artifact comes from shadowAttenuation property from Light structure, which I use to add shades on my object. I made a scene to show that.


Left cube uses Universal Render Pipeline/Lit shader (which comes out of the box with the URP package) and behaves absolutely normally.
Right cube uses my shader and has the artifact.
Middle cube uses modified version of my shader, which returns light.shadowAttenuation in fragment function. Also has the artifact.
The distance from cubes to the camera is around 10 meters, which equals to Split 1 property, which means that the artifact happens on the cascade split border.

Shader code for middle cube:

Shader "Hidden/showcase" {
    Properties {
    }
    SubShader {
        Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalRenderPipeline"}
        Pass {
            Name "StandardLit"
            Tags{"LightMode" = "UniversalForward"}

            HLSLPROGRAM

            #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"

            #pragma vertex vert
            #pragma fragment frag

            struct Attributes {
                float3 positionOS : POSITION;
            };

            struct v2f {
                float4 positionCS : SV_POSITION;
                float4 shadowCoords : TEXCOORD0;
            };

            v2f vert(Attributes IN) {
                v2f OUT = (v2f)0;

                VertexPositionInputs vertexPositionIn = GetVertexPositionInputs(IN.positionOS);
                OUT.shadowCoords = GetShadowCoord(vertexPositionIn);
                OUT.positionCS = vertexPositionIn.positionCS;

                return OUT;
            }

            half4 frag(v2f IN) : SV_TARGET {
                Light light = GetMainLight(IN.shadowCoords);
                return light.shadowAttenuation;;
            }

            ENDHLSL
        }
    }
}

Shader code for right cube:

Shader "Hidden/showcase2" {
    Properties {
        [MainTexture] tex ("Texture", 2D) = "white" {}
    }
    SubShader {
        Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalRenderPipeline"}
        Pass {
            Name "StandardLit"
            Tags{"LightMode" = "UniversalForward"}

            HLSLPROGRAM
            #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"

            #pragma vertex vert
            #pragma fragment frag

            TEXTURE2D(tex);
            SAMPLER(samplertex);
            float4 tex_ST;

            struct Attributes {
                float3 positionOS : POSITION;
                float3 normal : NORMAL;
                float2 uv : TEXCOORD0;
                float4 tangent : TANGENT;
            };

            struct v2f {
                float4 positionCS : SV_POSITION;
                float2 uv : TEXCOORD0;
                float3 positionWS : TEXCOORD1;
                float3 normal : TEXCOORD2;
                float4 shadowCoords : TEXCOORD3;
            };

            v2f vert(Attributes IN) {
                v2f OUT = (v2f)0;

                VertexNormalInputs vertexNormalIn = GetVertexNormalInputs(IN.normal, IN.tangent);
                VertexPositionInputs vertexPositionIn = GetVertexPositionInputs(IN.positionOS);

                OUT.positionCS = vertexPositionIn.positionCS;
                OUT.normal = vertexNormalIn.normalWS;
                OUT.uv = TRANSFORM_TEX(IN.uv, tex);
                OUT.shadowCoords = GetShadowCoord(vertexPositionIn);

                return OUT;
            }

            half4 frag(v2f IN) : SV_TARGET {
                float4 color = SAMPLE_TEXTURE2D(tex, samplertex, IN.uv);

                Light l = GetMainLight(IN.shadowCoords);
                float shadow = l.shadowAttenuation;
                half3 diffuse = LightingLambert(l.color, l.direction, IN.normal)*shadow;
                half3 ambientcolor = half3(unity_SHAr.w, unity_SHAg.w, unity_SHAb.w);
                half3 ambdiffuse = lerp(ambientcolor, 1, diffuse);
                
                color *= half4(ambdiffuse, 1);
                return color;
            }

            ENDHLSL
        }
    }
}

I can’t find the issue directly. Maybe use these methods as a base: