#version 400

uniform sampler2D    alphaTex;
uniform sampler2D    sumTex;

in vec2 fragTexCoord;
out vec4 result;


// This is the actual code that is executed.
void main( void )
{
	vec2 fTexCoord  = vec2(fragTexCoord.x, 1-fragTexCoord.y);
	
	float alpha = texture( alphaTex, fTexCoord ).x;	
	if (alpha >= 1.0f)
		discard;
	
	vec4 color = texture( sumTex, fTexCoord );	
	
	result = (1.0-alpha) * color / color.w; 
}