-1 scale make stencil test not working?

I’m working with the planar shadow,the shadow pass as below:
pass {
Tags { “LightMode” = “ForwardBase”}
Blend SrcAlpha OneMinusSrcAlpha
Stencil {
Ref 1
Comp NotEqual
Pass replace
}
//ZTest Less
Cull Back
Offset -1,-1
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include “UnityCG.cginc”
float4 vert(float4 vertex: POSITION) : SV_POSITION
{
float3 litDir = float3(-0.1,-0.2,0.2);

float4 vt = mul(_Object2World, vertex);
vt.xz=vt.xz-(vt.y/litDir.y)*litDir.xz;
vt.y=0;

vt=mul(_World2Object,vt);
return mul(UNITY_MATRIX_MVP, vt);
}
float4 frag(void) : COLOR
{
return float4(0.1,0.1,0.1,0.6);
}
ENDCG
}//

}

but when I set the object scale is (-1, 1, 1), the stencil test not working and will overdraw the shadow as the picture

If you have 1 (or 3) negative scaling factors, the triangles will be flipped, so you’ll have to reverse the backface culling:

Cull Front

Cull Front or Cull Back does not work:(, I have already tested

How about setting the readmask and writemask of the stencil operation to 1?

Right now you’re writing 255, but comparing with 1, so you can still have overdraw.

Hello z-Tree,

What version of Unity did you notice this in?

Thanks,
Scott