LightMode causes magenta error without any explanation.

I’m trying to add a cginc file to a shader.

Here’s the cginc of a simple toon lighting.

#include "UnityCG.cginc"
#include "Lighting.cginc"
#include "AutoLight.cginc"

float _Glossiness;
float _ToonRamp;
float3 _ObjectColor;

struct MeshData
{
    float4 vertex : POSITION;
    float3 normal : NORMAL;
    float2 uv : TEXCOORD0;
};

struct Interpolator
{
    float4 vertex : SV_POSITION;
    float2 uv : TEXCOORD0;
    float3 normal : TEXCOORD1;
    float3 worldPos : TEXCOORD2;
    LIGHTING_COORDS(3,4)
};

Interpolator vert (MeshData v)
{
    Interpolator i;
    i.vertex = UnityObjectToClipPos(v.vertex);
    i.normal = UnityObjectToWorldNormal(v.normal);
    i.worldPos = mul(unity_ObjectToWorld, v.vertex);
    i.uv = v.uv;
    TRANSFER_VERTEX_TO_FRAGMENT(v); // Lighting Data Transfer
    return i;
}

fixed4 frag (Interpolator i) : SV_Target
{
    // Vectors for lights
    float3 L = normalize(UnityWorldSpaceLightDir(i.worldPos));
    float3 N = normalize(i.normal);
    float3 V = normalize(_WorldSpaceCameraPos-i.worldPos);
    float3 H = normalize(L + V);
    float3 colL = _LightColor0;
    // float attenuation = LIGHT_ATTENUATION(i);

    // Lambertian Lighting
    float lambert = dot(N, L);
    float3 diffuseLight = colL * saturate(lambert);
    // attenuation *= attenuation;
    diffuseLight *= _ObjectColor;

    // Toon Ramp
    diffuseLight = ceil(diffuseLight * _ToonRamp) / _ToonRamp;

    // Specular Lighting
    float3 specularLight = saturate(dot(H, N)) * (lambert >= 0);
    // Too much math for fragment shader. Should optimize
    float specularExponent = exp2(_Glossiness * 11) + 2;
    specularLight = pow(specularLight, specularExponent); // * _Glossiness if not toon lighting
    specularLight *= colL;
    // specularLight *= attenuation;

    // Toon Ramp
    specularLight = step(0.6, specularLight);

    // float fresnel = 1 - dot(N, V);

    return float4(diffuseLight + specularLight, 1);
}

So now my “Other Toon Shader .shader” includes this and it works!
But as soon as I add the LightMode tag inside the base pass, it starts screaming magenta without any debug information so I don’t know what it is.

Here’s the shader.

Shader "Unlit/Other Toon Shader" // That just happens to have toon lighting
{
    Properties
    {
        // Toon Lighting Properties must be declared
        _ToonRamp ("Toon Ramp", Range(1, 4) ) = 3
        _Glossiness ("Glossiness", Range(0,1)) = 0.25
        _ObjectColor ("Object Color", Color ) = (1,1,1,1)
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" "Queue" = "Geometry"}

        // Base Pass
        Pass
        {
            Tags { "LightMode" = "ForwardBase" }

            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #include "ToonLight.cginc"
            ENDCG
        }
       
        // // Add Pass
        // Pass {
        //     Tags { "LightMode" = "ForwardAdd" }
        //     Blend One One

        //     CGPROGRAM
        //     #pragma vertex vert
        //     #pragma fragment frag
        //     #pragma multi_compile_fwdadd
        //     #include "ToonLight.cginc"
        //     ENDCG
        // }
    }
}

Any idea as to why it does not work as soon as I put that Lightmode tag?

if you are using other render pipeline not legacy (ex. URP or others),
LightMode Tag are not same. You should use proper tag property. You can compare the properties of legacy RP and URP in theses sites.
https://docs.unity3d.com/Packages/c…nual/urp-shaders/urp-shaderlab-pass-tags.html