Add Shadow to a Shader

Hi guys, I’ve a problem with my Shader and I can’t to fix it. My shader make a lerp compared to the vertex position (if a vertex is above the origin, it make lerp for example). My problem is that my shader doesn’t get the shadows and I don’t know what to do that.
Someone can help me?

Thank you in advance to anyone who helps me to fix it.
I give you my shader for so you can watch :

Shader "Custom/TerrainColoring Normals"
{
    Properties
    {
        _Color1("Down Color", Color) = (1, 1, 1, 1)
        _Color2("Top Color", Color) = (1, 1, 1, 1)
       
       
        _Depth ("Depth", Float) = 10
       
    }
   
    SubShader
    {
       
        Pass
        {

            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"
           
            float4 _Color1;
            float4 _Color2;
           
            float _Depth;
           
            struct v2f
            {
                float4 pos : SV_POSITION;
                float3 color : COLOR0;
            };

            v2f vert (appdata_base v)
            {
                v2f o;
                o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
                o.color = o.color = lerp(_Color1, _Color2, (v.vertex.y+_Depth*0.5) / _Depth);
                return o;
            }

           
            half4 frag (v2f i) : COLOR
            {
                return half4 (i.color, 1);
            }
            ENDCG

        }
    }
    Fallback "VertexLit"
}

Do you mean projected shadows? I’m not sure I understand your question.

I mean that the shader does not receive shadows.
If I have an object on a plane, who have my Shader. We do not see the shadow on the plane.

Try this. I’ve indicated where I made changes.

    Shader "Custom/TerrainColoring Normals"
    {
        Properties
        {
            _Color1("Down Color", Color) = (1, 1, 1, 1)
            _Color2("Top Color", Color) = (1, 1, 1, 1)
          
          
            _Depth ("Depth", Float) = 10
          
        }
      
        SubShader
        {
          
            Pass
            {
                 // FOLLOWING LINE IS NEW
                 Tags {"LightMode" = "ForwardBase"}
    
                CGPROGRAM
                #pragma vertex vert
                #pragma fragment frag
                #include "UnityCG.cginc"
               
                // FOLLOWING TWO LINES ARE NEW
                #include "AutoLight.cginc"
                #pragma multi_compile_fwdbase
              
                float4 _Color1;
                float4 _Color2;
              
                float _Depth;
              
                struct v2f
                {
                    float4 pos : SV_POSITION;
                    float3 color : COLOR0;
                   
                    // FOLLOWING LINE IS NEW
                    LIGHTING_COORDS(0,1)
                };
    
                v2f vert (appdata_base v)
                {
                    v2f o;
                    o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
                    o.color = o.color = lerp(_Color1, _Color2, (v.vertex.y+_Depth*0.5) / _Depth);
                   
                    // FOLLOWING LINE IS NEW
                    TRANSFER_VERTEX_TO_FRAGMENT(o);
                   
                    return o;
                }
    
              
                half4 frag (v2f i) : COLOR
                {
                    // FOLLOWING LINE IS CHANGED
                   return half4 (i.color * LIGHT_ATTENUATION(i), 1);
                }
                ENDCG
    
            }
        }
       Fallback "VertexLit"
    }

Thank you alot tanoshimi, it works perfectly :slight_smile: and now I can add shadows to my future Shaders. Thank you again.