in vec2 Texcoord;
in vec4 Color;

uniform sampler2D tex;
uniform float alphaRef;
uniform UBOOL alphaTest;
uniform UBOOL useTexture;
uniform UBOOL enableFog;
uniform vec4 fogColor;
uniform vec4 ambient;
uniform int effectId;
uniform UBOOL effectSecondPass;

varying float fogFactor;

OUTPUT

void main() {
	if (effectId == 0) {
		outColor = Color;

		if (useTexture) {
			outColor = texture(tex, Texcoord) * outColor;
		}

		if (enableFog) {
			outColor.rgb = mix(fogColor.rgb, outColor.rgb, fogFactor);
		}

		if (UBOOL_TEST(alphaTest) && outColor.a < alphaRef) {
			discard;
		}
	} else if (effectId == 1) {
		if (UBOOL_TEST(effectSecondPass)) {
			outColor = texture(tex, Texcoord) * ambient;
		} else {
			outColor = Color;
		}
	}
}
