I wrote this shader
to illustare alpha test
action in GLES2
(Galaxy S6).
I think is not working at all cause I don't see any change with or without it.
Is there anything Im missing?
Any syntax error?
I know its better not using if
in shader
but for now this is the solution I need.
precision highp float;
precision highp int;
precision lowp sampler2D;
precision lowp samplerCube;
//0 - CMPF_ALWAYS_FAIL,
//1 - CMPF_ALWAYS_PASS,
//2 - CMPF_LESS,
//3 - CMPF_LESS_EQUAL,
//4 - CMPF_EQUAL,
//5 - CMPF_NOT_EQUAL,
//6 - CMPF_GREATER_EQUAL,
//7 - CMPF_GREATER
bool Is_Alpha_Pass(int func,float alphaRef, float alphaValue)
{
bool result = true;
if (func==0)
{
result = false;
break;
}
if (func==1)
{
result = true;
break;
}
if (func==2)
{
result = alphaValue < alphaRef;
break;
}
if (func==3)
{
result = alphaValue <= alphaRef;
break;
}
if (func==4)
{
result = alphaValue == alphaRef;
break;
}
if (func==5)
{
result = alphaValue != alphaRef;
break;
}
if (func==6)
{
result = alphaValue >= alphaRef;
break;
}
if (func==7)
{
result = alphaValue > alphaRef;
break;
}
return result;
}
void FFP_Alpha_Test(in float func, in float alphaRef, in vec4 texel)
{
if (!Is_Alpha_Pass(int(func), alphaRef, texel.a))
discard;
}