in vec2 Texcoord;
in vec4 Color;

uniform sampler2D tex;
uniform bool textured;
uniform bool swapRandB;
uniform float alphaRef;
uniform float meshAlpha;

OUTPUT

void main()
{
	outColor = Color;
	if (textured) {
		vec4 texColor = texture(tex, Texcoord);
#ifdef GL_ES
		if (swapRandB)
			texColor.rb = texColor.br;
#endif
		outColor.rgba *= texColor.rgba;
		outColor.a *= meshAlpha;
		if (outColor.a < alphaRef)
			discard;
	}
}
