I try to do my own custom shader and wanted to used clip/discard instead of fixed function pipeline Alpha testing.
I force my shader to compile in SM 3.0 but
when I test my custom shader with clip instruction, the pixel still be writted.
And it is written with a wrong value (generaly a pixel from a texture appled on it) instead of being kill.
You can reproduce the problem just with the following shader:
float4 frag (v2f i) : COLOR
{
clip(-1);
return 1;
}
You can observe that pixel are not kill.
Note that my shader begin with this:
Category {
Tags { “RenderType”=“Opaque” }
LOD 200
Fog { Color [_AddFog] }
Pass {
ZTest Always
Cull Off
ZWrite Off
Fog { Mode off }
Blend Off
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
float4 frag (v2f_img i) : COLOR
{
//Never render the proxy shader in scene
//Just use it for shader replace
clip( -1.0 );
return float4( 1.0, 0.0, 0.0, 1.0 );
}
ENDCG
}