Hi all,
I had a problem in the implementation of deferred shadow mapping, on a mac (OpenGL / GLSL) everything goes well, but in windows (directx / HLSL) is not going well.
More details can be seen in the following video,
screencast
I construct the world position like this,
// Recreate the position with the UV coordinates and depth value
float4 position;
position.x = texCoord.x * 2.0f - 1.0f;
position.y = (1.0f - texCoord.y) * 2.0f - 1.0f;
position.z = depth.r;
position.w = 1.0f;
// Transform position from screen space to world space
position = mul(position, InverseViewProjection);
position.xyz /= position.w;
position.w = 1.0f;
and shadow position like this,
// Calculate homogenous position with respect to light
float4 lightScreenPosition = mul(position, LightViewProjection);
// Find sample position in shadow map
float2 shadowTexCoord = postProjToScreen(lightScreenPosition) + ShadowMapPixelSize;
And the helper function,
float2 postProjToScreen(float4 position)
{
float2 screenPosition = position.xy / position.w;
return 0.5f * (float2(screenPosition.x, -screenPosition.y) + 1.0f);
}
What’s wrong with my shader? there a solution?
Thank,
Byu