Shader using UV4 renders fine in scene view but not in game mode

A custom shader I wrote for a 2D face rig of mine has recently stopped working in Unity. Before the shader used to render correctly both in the scene view and in the game view but something happened along the line I guess.
Here is all of that I can provide, but it seems that Unity has stopped rendering fragments in the UV4 channel (if that makes sense). Also I’m on the standard/built-in rendering pipeline.




Here is the vertex and fragment shader:

    v2f vert (appdata v)
    {
        v2f o;
     
        UNITY_SETUP_INSTANCE_ID(v);
        UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

        o.vertex = UnityObjectToClipPos(v.vertex);

        o.uv0 = v.uv0;                                                                                      // Base texture uvs
        o.uv1 = (((v.uv1 - float2(0, 1)) * _UVEyeScale) + float2(0, 1)) + _UVEyeOffset;                     // Eye texture uvs
        o.uv2 = (((v.uv2 - float2(0.5, 0.5)) * (1 / _UVPupilScale)) + float2(0.5, 0.5)) + _UVPupilOffsetL;  // L Pupil
        o.uv3 = (((v.uv3 - float2(0.5, 0.5)) * (1 / _UVPupilScale)) + float2(0.5, 0.5)) + _UVPupilOffsetR;  // R Pupil
        o.uv4 = (((v.uv4 - float2(0, 1)) * _UVMouthScale) + float2(0, 1)) + _UVMouthOffset;                 // Mouth texture uvs

        float4 lighting = float4(ShadeVertexLightsFull(v.vertex, v.normal, 4, true), 1);
        o.diff = lighting * _Color;

        UNITY_TRANSFER_FOG(o,o.vertex); // Pass fog

        return o;
    }

    fixed4 frag (v2f i) : SV_Target
    {
        fixed4 faceColor = tex2D(_FaceTexture, i.uv0);
        fixed4 eyeColor = tex2D(_EyeTexture, i.uv1);
        fixed4 mouthColor = tex2D(_MouthTexture, i.uv4);

        fixed4 pupilColorL = tex2D(_PupilTextureL, i.uv2);
        fixed4 pupilColorR = tex2D(_PupilTextureR, i.uv3);

        fixed4 pupilsColor = (eyeColor * pupilColorL) * (eyeColor * pupilColorR);

        fixed4 finalColorE = lerp(faceColor, pupilsColor, eyeColor.a);
        fixed4 finalColorM = lerp(finalColorE, mouthColor, mouthColor.a);

        finalColorM.a = mouthColor.a + eyeColor.a + faceColor.a;

        // Lighting
        fixed4 diffColor = finalColorM;
        diffColor.xyz = diffColor.xyz * i.diff.xyz;
        diffColor.w = diffColor.w * i.diff.w;

        finalColorM = lerp(diffColor, finalColorM, _Emission);

        // Apply fog
        UNITY_APPLY_FOG(i.fogCoord, finalColorM);

        return finalColorM;
    }
    ENDCG
}

And the data structs:

struct appdata
{
    float4 vertex : POSITION;
    float3 normal : NORMAL;
    float2 uv0 : TEXCOORD0;
    float2 uv1 : TEXCOORD1;
    float2 uv2 : TEXCOORD2;
    float2 uv3 : TEXCOORD3;
    float2 uv4 : TEXCOORD4;          
};

struct v2f
{
    float2 uv0 : TEXCOORD0;
    float2 uv1 : TEXCOORD1;
    float2 uv2 : TEXCOORD2;
    float2 uv3 : TEXCOORD3;
    float2 uv4 : TEXCOORD4;
    UNITY_FOG_COORDS(6)
    float4 vertex : SV_POSITION;
    fixed4 diff : COLOR0;
    UNITY_VERTEX_OUTPUT_STEREO
};

Thanks again!

Did you change something recently? If so, try reverting it!!

Or just checkout an earlier version of your project (assuming you’re using source control).

If you didn’t change anything then perhaps there’s a call to do a Reimport-All.

Another thing to do is make a build and check the logs when it starts running.

I’m unfortunately not using source control but I’ve given a shot at reimporting-all, still the issue persists. Adding the model to a new scene and it renders fine however. I figured it could’ve been realtime illumination messing up with UVs or who knows so I disabled it in my scenes and still nothing changed. Even in scenes without baked lighting the shader displays incorrectly. This wouldn’t matter that much if in builds the shader rendered correctly, but that isn’t the case. Also builds don’t yield any errors. I don’t really know anymore lol.

Edit: The shader renders correctly on a quad, layering also the UV4 texture on it. Tried re-exporting the model, nothing changes. So it’s not a scene related issue? It seems that no matter how I export my model Unity doesn’t like it.

I don’t know why or how but a script I had for a datamoshing effect forked from Kino effects caused the issue. I don’t even know how it’s possible but now the shader renders always correctly.