Creating a world space clippable for lit shaders in HDRP

Hi all,
I’m trying setup a clippable shader for lit shader in HDRP, that clips by world space Y axis. I have tried referring to the advice provided in this forum,
https://forum.unity.com/threads/shader-graph-how-to-make-a-simple-clipping-shader.583513/

However when I created the lit shader graph, I realized that I have to set the mode to transparent to utilize the alpha clipping. I also noticed artifacts when i use the alpha clipping in the transparent pass with my other objects. So I would prefer to do something similar to the hdrp shader I attempted to write below here that provides primitive clipping and simple shadow casting for opaque objects.

It would help if anyone can advise on extending the shader below to do something akin to receiving shadows in HDRP since I couldn’t get the shader graph to work with opaque type materials.


Shader "Custom/DuctClipping"
{
    Properties
    {
        _Color("Color", Color) = (1,1,1,1)
        [NoScaleOffset] _MainTex("Texture", 2D) = "white" {}
        _SliceValTopY("TopSliceY", Float) = 100000
        _SliceValBotY("BotSliceY", Float) = -100000
  
    }

   HLSLINCLUDE
   #pragma target 4.5

   //enable GPU instancing support
   #pragma multi_compile_instancing
   ENDHLSL
       
    SubShader
    {
        //unity has in-built passes but writing to them just screws everything up. for the main pass, we dont specify a pass, but for sub pass we can use unity's prespecified
         Pass
         {
              //HLSLPROGRAM
              CGPROGRAM
                // use "vert" function as the vertex shader
                #pragma vertex vert
                // use "frag" function as the pixel (fragment) shader
                #pragma fragment frag


                // vertex shader inputs
                struct appdata
                {
                    float4 vertex : POSITION; // vertex position
                    float2 uv : TEXCOORD0; // texture coordinate
                };
        
                struct v2f
                {
                    float2 uv : TEXCOORD0; // texture coordinate
                    float4 vertex : SV_POSITION; // clip space position
                    float3 worldPos : TEXCOORD1; // world space position
                };
        
                sampler2D _MainTex;
                // vertex shader
                v2f vert(appdata v)
                {
                    v2f o;
                    // o.vertex = TransformObjectToHClip(v.vertex);
                     o.vertex = UnityObjectToClipPos(v.vertex);
                     o.uv = v.uv;
                   //  o.uv = TRANSFORM_TEX(v.uv, _MainTex);
        
                     // pass the world space position
                     o.worldPos = mul(UNITY_MATRIX_M, v.vertex).xyz;

        
                     return o;
                 }
        
        
                 half4 _Color;
                 float _SliceValTopY;
                 float _SliceValBotY;
        
                 // color ("SV_Target" semantic)
                 half4 frag(v2f i) : SV_Target
                 {
                     if (_SliceValTopY != 100000) //use this value as the default value to not process, since shader essentially uses float as bool
                         clip(_SliceValTopY - i.worldPos.y);
        
                     if (_SliceValBotY != -100000)
                         clip(i.worldPos.y - _SliceValBotY);

                     half4 col = tex2D(_MainTex, i.uv) * _Color;
        
                     return col;
                 }
        
                 //ENDHLSL
                 ENDCG
         }
    
        // Copy fromm shader graph default shader
        Pass
        {
            Name "ShadowCaster"
            Tags
            {
                "LightMode" = "ShadowCaster"
            }
                 // Render State
           Cull[_CullMode]
           ZWrite On
           ColorMask 0
           ZClip[_ZClip]
    
           HLSLPROGRAM
           #include "ShadowPass.hlsl"
           ENDHLSL
        }
    }
}