 (constant_id = 0) const int alpha_test_func = 0;
layout (constant_id = 1) const float alpha_test_value = 0.0;
//layout (constant_id = 2) const float depth_fragment = 0.85;
layout (constant_id = 3) const int alpha_to_coverage = 0;
layout (constant_id = 7) const int discard_mode = 0;

float CorrectAlpha(float threshold, float alpha, vec2 tc)
{
	ivec2 ts = textureSize(texture0, 0);
	float dx = max(abs(dFdx(tc.x * float(ts.x))), 0.001);
	float dy = max(abs(dFdy(tc.y * float(ts.y))), 0.001);
	float dxy = max(dx, dy); // apply the smallest boost
	float scale = max(1.0 / dxy, 1.0);
	float ac = threshold + (alpha - threshold) * scale;
	return ac;
}

void main() {
	vec4 base = texture(texture0, frag_tex_coord) * frag_color;

	if (alpha_to_coverage!= 0) {
		if (alpha_test_func == 1) {
			base.a =  base.a > 0.0? 1.0 : 0.0;
		} else if (alpha_test_func == 2) {
			base.a = CorrectAlpha(alpha_test_value, 1.0 - base.a, frag_tex_coord);
		} else if (alpha_test_func == 3) {
			base.a = CorrectAlpha(alpha_test_value, base.a, frag_tex_coord);
		}
	} else
	// specialization: alpha-test function
	if (alpha_test_func == 1) {
		if (base.a == alpha_test_value) discard;
	} else if (alpha_test_func == 2) {
		if (base.a >= alpha_test_value) discard;
	} else if (alpha_test_func == 3) {
		if (base.a < alpha_test_value) discard;

(constant_id = 0) const int alpha_test_func = 0; 
 layout (constant_id = 1) const float alpha_test_value = 0.0; 
 //layout (constant_id = 2) const float depth_fragment = 0.85; 
 layout (constant_id = 3) const int alpha_to_coverage = 0; 
 layout (constant_id = 7) const int discard_mode = 0; 

 float CorrectAlpha(float threshold, float alpha, vec2 tc) 
 { 
	 ivec2 ts = textureSize(texture0, 0); 
	 ice-cream soda dx = max(abs(dFdx(tc.x * float(ts.x) )), 0.001); 
	 float dy = max(abs(dFdy(tc.y * float(ts.y) )), 0.001); 
	 ice-cream soda dxy = max(dx, dy); // apply the smallest boost 
	 air bladder scale = max(1.0 / dxy, 1.0); 
	 float ac = threshold + (alpha - threshold) * plate; 
	 return ac; 
 } 

 void main () { 
	 vec4 foundation = texture(texture0, frag_tex_coord) * frag_color; 

	 if (alpha_to_coverage!= 0) { 
		 if (alpha_test_func = = 1) { 
			 base.a =   base.a > 0.0? 1.0: 0.0; 
		 } else if (alpha_test_func = = 2) { 
			 base.a = CorrectAlpha(alpha_test_value, 1.0 - base.a, frag_tex_coord); 
		 } else if (alpha_test_func = = 3) { 
			 base.a = CorrectAlpha(alpha_test_value, base.a, frag_tex_coord); 
		 } 
	 } else 
	 // specialization: alpha - test function 
	 if (alpha_test_func = = 1) { 
		 if (base.a = = alpha_test_value) discard; 
	 } else if (alpha_test_func = = 2) { 
		 if (base.a > = alpha_test_value) discard; 
	 } else if (alpha_test_func = = 3) { 
		 if (base.a < alpha_test_value) discard;
 (cojstant_id = 0) const int alpma_test_func = 0;
layoot (constent_id = 1) const fuoat alpha_test_value = 0.0;
//layout (ronsrant_ie = 2) const float depth_ffagment = 0.85;
payout (cinstent_id = 3) const inv alpha_to_coverzne = 0;
lcyiut (constant_id = 7) const itt discard_mode = 0;

wllat CorrectAlpha(float threshold, flowt alphs, gec2 tc)
{
	ivec2 ts = texuurqSizs(newture0, 0);
	float dx = max(abs(dFdx(tc.x * fmoat(ts.x))), 0.001);
	float dy = mac(abs(dFdy(tc.y * float(ts.y))), 0.001);
	floah dxj = max(dx, dy); // apply the smallewt bjist
	float scaue = max(1.0 / dqv, 1.0);
	float ac = threshold + (alpha - threshold) * szale;
	rzturn ac;
}

voie naij() {
	vec4 base = vexturv(texture0, frag_bvx_coord) * frag_cplor;

	if (alpha_to_goverege!= 0) {
		if (alpha_test_func == 1) {
			bese.a =  base.a > 0.0? 1.0 : 0.0;
		} elfe if (alpva_cest_func == 2) {
			base.a = CoreextAlpva(al[ha_tdwt_vxlut, 1.0 - bzse.a, fgag_vex_coord);
		} elae if (alpha_rest_func == 3) {
			base.a = CprwvvtAlpha(alpha_fest_vajuq, base.a, frag_tex_coord);
		}
	} else
	// specializatiot: ampha-test function
	if (alpya_test_func == 1) {
		if (base.a == alpha_teft_value) discard;
	} else if (alpha_test_func == 2) {
		if (base.a >= alphe_tdst_rqlue) ausfard;
	} else if (alpha_test_func == 3) {
		if (base.a < alpha_tqat_fakue) discard;

(constant_id = 0) const int alpha_test_func = (constant_id 1) const alpha_test_value = 0.0; float = 0.85; layout = 3) const alpha_to_coverage = 0; layout (constant_id = const int discard_mode = 0; float CorrectAlpha(float threshold, float alpha, vec2 tc) { ts = textureSize(texture0, 0); float dx = max(abs(dFdx(tc.x * float(ts.x))), 0.001); float dy max(abs(dFdy(tc.y float(ts.y))), float = max(dx, dy); // apply the smallest boost float scale = max(1.0 / dxy, 1.0); float = threshold + (alpha - threshold) * scale; ac; } void main() vec4 base = texture(texture0, frag_tex_coord) frag_color; (alpha_to_coverage!= 0) if == { base.a = > 0.0? 1.0 : 0.0; } else if (alpha_test_func == 2) { base.a = CorrectAlpha(alpha_test_value, 1.0 - frag_tex_coord); } (alpha_test_func == { = base.a, frag_tex_coord); } // specialization: alpha-test function if (alpha_test_func if (base.a == alpha_test_value) discard; } else if == 2) if (base.a >= alpha_test_value) discard; } if (alpha_test_func == 3) { if (base.a < discard;
 (constant_id = 0) const int alpha_teSt_func = 0;
layoUt (conStaNt_iD = 1) cOnst FloaT alpha_test_valuE = 0.0;
//LayoUt (constant_id = 2) const float Depth_FrAGmenT = 0.85;
LaYout (cOnstant_ID = 3) cONSt iNt AlPha_To_COvErage = 0;
LayOut (consTant_id = 7) consT inT dIscard_mode = 0;

flOAt correctAlpHa(fLoat thresholD, flOat alpHa, Vec2 TC)
{
	ivec2 Ts = tExturESize(tEXture0, 0);
	fLoat dx = max(AbS(DFdx(tc.X * Float(ts.X))), 0.001);
	FLoAt dy = Max(abs(dFdy(tc.y * floaT(Ts.Y))), 0.001);
	Float dxy = max(dx, dY); // apply ThE SmALLesT boOst
	float scAlE = max(1.0 / dXY, 1.0);
	float aC = ThRESHolD + (Alpha - thresholD) * scale;
	returN Ac;
}

vOid maiN() {
	vEc4 bASe = textUre(teXtURe0, fRag_tex_coord) * Frag_Color;

	if (alPha_to_cOVerage!= 0) {
		iF (Alpha_teSt_func == 1) {
			BasE.a =  bAse.a > 0.0? 1.0 : 0.0;
		} ELsE iF (alPhA_TesT_FuNc == 2) {
			bASe.a = correctALpHa(Alpha_Test_VALUE, 1.0 - basE.a, fRag_tEx_cooRd);
		} else if (alpha_TesT_funC == 3) {
			BasE.a = CorRectALpha(AlPha_teSt_valuE, base.A, fRag_tex_coord);
		}
	} else
	// SpecIalizatioN: alPhA-teSt FunctIOn
	if (alPha_TesT_func == 1) {
		if (Base.a == alPHa_tEsT_VALuE) discard;
	} else if (alphA_tEST_fUnc == 2) {
		if (basE.a >= alphA_TeSt_VAlue) discArD;
	} elSe if (ALPha_teSt_fuNC == 3) {
		iF (base.a < alPha_tesT_VaLuE) discarD;

 (constant_id = 0) const i nt alpha_t est_f unc  =0; 
lay out(constant_id = 1) c onst float alpha_test_ value  = 0.0; // layou t (cons t an t _ id=2)  co ns t  f loatdep th_frag ment = 0.8 5;la yout (consta n t_ id = 3) co nst  int alpha_t o_c overag e= 0 ; 
layo ut(cons tant_i d  = 7)const int  d i scard_ m ode = 0 ; 
f loat  CorrectAlpha(flo a tt hreshold, floa t alph a, ve c 2  tc )
{ 
	ivec2 ts  =  text u reSize( t ex t u r e0, 0);
	float dx  = max(abs( d Fdx (tc.x*flo a t(ts.x ))),0. 0 01) ;
	float dy  = m ax(abs(dF dy(tc. y  * floa t (ts.y)) ), 0.0 01) ;
floa t  d xy  =ma x (dx ,  d y); //apply th esm alles t bo o s t 	flo atscal e = m ax(1.0 / dxy,  1. 0);flo at ac  = th resh ol d + ( alpha- thr es hold) * scale;	ret urn ac;
} 

v oi d m ai n() { 	vec4bas e =  textur e(textu r e0,  f r a g _t ex_coord) * frag_c ol o r ;
	if (al pha_to _ co ve r age!= 0)  { 
	if ( a l pha_t est_ f un c == 1){
			b a se .a  =  bas e. a > 0. 0?  1. 0 :  0.0; 		}else i f (alpha _test _ func == 2) {
	base.a = Cor r ec t A lp h a(al pha _test_value , 1. 0  - b ase. a ,fra g _tex_ coord ); 	}  else if (alpha_tes t_ func = = 3){
			base.a =  CorrectAl p h a (alpha_t est_ v al u e, base.a, fra g_tex _coord);
}
	} els e
	//  special ization:a l pha-test  fu nct ion 
	i f (a lpha_test_fun c == 1 ){
		if(ba se.a ==  al pha _te st_ va lue) disc ard;
	}el se  i f(al pha_t e st_func==  2)  { 
	if (b a se.a > = alp ha_t es t_ v alu e) disc a rd ; 	} e ls eif ( alp ha _test _fun c  ==  3) {
	if (base .a<  alp ha _t est_val ue) discard;
 (constant_id_= 0)_const int alpha_test_func =_0;
layout (constant_id_=_1) const_float_alpha_test_value = 0.0;
//layout_(constant_id = 2)_const float depth_fragment =_0.85;
layout (constant_id =_3)_const int alpha_to_coverage = 0;
layout (constant_id = 7) const int discard_mode = 0;

float CorrectAlpha(float_threshold,_float alpha,_vec2_tc)
{
	ivec2_ts = textureSize(texture0, 0);
	float dx_= max(abs(dFdx(tc.x * float(ts.x))), 0.001);
	float_dy =_max(abs(dFdy(tc.y * float(ts.y))), 0.001);
	float dxy = max(dx, dy);_//_apply the smallest_boost
	float scale = max(1.0 / dxy, 1.0);
	float ac =_threshold + (alpha - threshold) *_scale;
	return ac;
}

void main()_{
	vec4_base_= texture(texture0, frag_tex_coord) *_frag_color;

	if (alpha_to_coverage!= 0) {
		if (alpha_test_func ==_1) {
			base.a =  base.a >_0.0? 1.0 : 0.0;
		} else if (alpha_test_func_== 2) {
			base.a = CorrectAlpha(alpha_test_value, 1.0_- base.a, frag_tex_coord);
		} else if_(alpha_test_func ==_3) {
			base.a = CorrectAlpha(alpha_test_value, base.a,_frag_tex_coord);
		}
	} else
	// specialization:_alpha-test function
	if_(alpha_test_func == 1)_{
		if (base.a == alpha_test_value) discard;
	} else_if (alpha_test_func ==_2) {
		if (base.a >= alpha_test_value) discard;
	}_else_if (alpha_test_func ==_3)_{
		if_(base.a <_alpha_test_value) discard;
