// All content © 2010-2011 DigiPen (USA) Corporation, all rights reserved.

//Fragment shader to add glow textures to the final scene texture

#version 150

// ---------------------------------------------------------------------------
//uniforms

//textures
uniform sampler2D		uScene; //scene texture
uniform sampler2D		uBlur; //blur texture
uniform sampler2D		uGlowMap; //glow map from gbuffer pass
uniform sampler2D		uLightBuffer; //light buffer
uniform float			uMaxGlow; //total glow amount

// ---------------------------------------------------------------------------
// from vertex shader

in vec2					vTexCoord;

// ---------------------------------------------------------------------------
// const

const vec3				LUMINANCE = vec3( 0.2126, 0.7152, 0.0722 );

// ---------------------------------------------------------------------------
// output

out vec4				out_Color; 


void main()
{
	ivec2 tc = ivec2( gl_FragCoord.xy );

	//float lightIntensity = dot( texelFetch(uLightBuffer, tc, 0).rgb, LUMINANCE );
	vec4 sceneColor = texelFetch( uScene, tc, 0 );
	
	/*if ( lightIntensity > 0.0 )
		out_Color = sceneColor;
	else*/
		out_Color = sceneColor + texture( uBlur, vTexCoord ) * (texelFetch( uGlowMap, tc, 0 ).a * uMaxGlow);
}





