//
//  Decals2d.fsh  --  apply TeamColor to Decal Page for 2D viewing
//  PlayMate
//
//  Created by David McKibbin on 10/13/13.
//  Copyright (c) 2012 Firaxis Games. All rights reserved.
//

#ifdef GL_ES
precision mediump int;		// built-in defaults
precision highp   float;
precision lowp    sampler2D;
precision lowp    samplerCube;
#endif

// Inputs
varying   vec4	v_Color;
varying   vec2	v_TexUV;

// Constants
uniform  sampler2D	BaseMap;
uniform  float		AlphaTest;

void main()
{
	vec4 decal = texture2D( BaseMap, v_TexUV );

	if (decal.rgb == vec3(0.0))		// chroma-key: RGB=0
	{
		decal.rgb = decal.a * v_Color.rgb;	// pre-mul by decal alpha
	}

	gl_FragColor = decal;

//	if (gl_FragColor.a < AlphaTest)  discard;	// Alpha test
}
