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

//shader to render basic shadows.

#version 150

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

uniform sampler2D		uDepthMap; //depth map for this light

uniform mat4			uVtL; //view to light space matrix
uniform mat4			uLsp; //bias matrix * light projection matrix

uniform float			uLightFarPlane; //light far plane - light near plane
uniform float			uTexelSize; //1.0/shadowmapsize

// ---------------------------------------------------------------------------
// function declarations

float calcShadow( in vec3 viewSpacePos );

//internal functions
float pcf( in vec2 tc, float lsDepth );

float calcShadow( in vec3 viewSpacePos )
{	
	//get light space position
	vec4 lsPos = uVtL * vec4( viewSpacePos, 1.0 );
	
	float shadowMapDepth = textureProj( uDepthMap, uLsp * lsPos ).r * uLightFarPlane;
	return -lsPos.z > shadowMapDepth - 0.001? 0.0 : 1.0;	
}
