They use a texture2d for the shadowmapping and saving the depth value in it. What i understand now is that you want to map the texcoord values [-1, 1] to [0, 1] and you do this by scaling and biasing. Tex.xy * float2(0.5, 0.5)+0.5.
But what they do is that they use a negative 0.5 on the y variable. Why?
tex.xy = Tex.xy * float2(0.5, -0.5)+0.5. They are using Directx 10.
Here is the vertex and pixel shader:
PSIn VSDrawScene( VSIn input )
{
PSIn output = (PSIn)0.0f;
output.tex = input.tex;
float4 worldPos = mul( float4( input.pos, 1.0f ), mWorld );
float4 lightViewPos = mul( worldPos, mShadowView );
float3 lightVec = vLightPos.xyz - worldPos.xyz;
output.pos = mul( mul( worldPos, mView ), mProj );
output.lightViewPos = mul( lightViewPos, mShadowProj );
output.wNorm = normalize( mul( float4( input.norm, 0.0f ), mWorld ) );
output.wLight = normalize( lightVec );
return output;
}
float4 PS( uniform bool bVSM, PSIn input ) : SV_Target
{
float4 output = (float4)0.0f;
input.lightViewPos.xyz /= input.lightViewPos.w;
float2 tex = input.lightViewPos.xy *float2(0.5, -0.5) + 0.5f;
float lit = PCF_FILTER( tex, input.lightViewPos.z );
float3 wLight = normalize( input.wLight );
float3 wNormal = normalize( input.wNorm );
float3 diffuse = texDiffuse.Sample( FILT_LINEAR_WRAP, texScaled );
diffuse *= dot( normalize( wNormal ), wLight );
return float4( diffuse, 1.0f ) * lit;
}












