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

//Fragment shader for fog effect in domain

#version 150

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

//textures
uniform sampler2D		uNormalDepth; //normal depth buffer from the gbuffer pass
uniform sampler2D		uDiffuse;
uniform float			uAlpha;  
uniform float			uCamFarPlane;

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

in vec2					vTexCoord;
in float				vVSDepth; //view space depth 

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

const float FADE_SCALE	= 500.0; //used to fade fog against objects

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

out vec4				out_Color;

// ---------------------------------------------------------------------------

void main()
{
	vec4 color = texture( uDiffuse, vTexCoord );
	out_Color = vec4(	color.rgb, 
						color.a * 
						clamp( ( texelFetch(uNormalDepth,ivec2( gl_FragCoord.xy ),0).a - vVSDepth/uCamFarPlane ) * FADE_SCALE, 0.0, 1.0 ) *
						 uAlpha );
}





