uniform sampler2D tex0;

uniform sampler2D mask;

uniform int channel;
uniform int invert;

void main(void)
{
	vec4 color = texture2D(tex0, gl_TexCoord[0].st);
	vec4 m = texture2D(mask, gl_TexCoord[0].st);
  
  if (invert == 0)
    color.a *= m[channel];
  else
    color.a *= (1.0 - m[channel]);
  
	gl_FragColor = color;  
}
