
// Shadow caster vertex program.

void casterVP(
	float4 position			: POSITION,
	out float4 outPos		: POSITION,
	out float2 outDepth		: TEXCOORD0,

	uniform float4x4 worldViewProj,
	uniform float4 texelOffsets,
	uniform float4 depthRange
)
{
	outPos = mul(worldViewProj, position);

	// fix pixel / texel alignment
	outPos.xy += texelOffsets.zw * outPos.w;
	
	outDepth.x = outPos.z;
	outDepth.y = outPos.w;
}

// Shadow caster fragment program for high-precision single-channel textures	
void casterFP(
	float2 depth			: TEXCOORD0,
	out float4 result		: COLOR)
{
	float finalDepth = depth.x / depth.y;

	// just smear across all components 
	// therefore this one needs high individual channel precision
	result = float4(finalDepth, finalDepth, finalDepth, 1);
}
