Hi everybody, I'm trying to set up a shadow map into a deferred rendering process. Here is my fragment shader :
//vec4 vPositionPXWorldSpace is the world space coord of current pixel, from a g-buffer texture
//mat4 matLightView/ matLightProj my view & proj light matrix
//sampler2D tShadowMap the depth map from light point of view
//mat4 biasMatrix the standard biasmatrix to convert from screenspace to texturespace
vec4 FragCoordLightViewSpace = matLightView * vPositionPXWorldSpace;
vec4 FragCoordLightProjSpace = matLightProj * FragCoordLightViewSpace;
FragCoordLightProjSpace /= FragCoordLightProjSpace.w;
vec4 FragCoordShadowTexCoord = biasMatrix * FragCoordLightProjSpace;
float fShadowFactor = texture2D( tShadowMap, FragCoordShadowTexCoord.st).x;
if(fShadowFactor < FragCoordLightProjSpace.z) fShadowFactor = 0.5;
else fShadowFactor = 1;
FragColor = lightResult * fShadowFactor ;
gl_FragData[1] = vec4(fShadowFactor, fShadowFactor, fShadowFactor, 1.0);
but i obtain a full white result, fShadowFactor is everytime = 1. What do I wrong ? Tell me if you need something more. Thanks.