This topic is 1732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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;

FragColor = lightResult * fShadowFactor ;


but i obtain a full white result, fShadowFactor is everytime = 1. What do I wrong ? Tell me if you need something more. Thanks.

##### Share on other sites

There are lots of things that can go wrong.

Make sure:

1. The shadow map is bound correctly and you can read values from it using texture2D in the shader. The uniform value of tShadowMap might be setup wrong, the shadow map might be bound to the wrong unit, it is highly possible the sampler state is the culprit (expecting mip-maps that are not present for the generated shadow map).

2. The matrices are correct. Test in on the CPU with a few points and then make sure the results are correct. You might test setting the output color to the computed frag coords to make sure those are correct.

3. gl_FragData[1] writes to the second bound MRT buffer. Don't you want to write to the first?

These are probably the most common mistakes, but it could still be something different. Like a wrong format or errors when rendering the shadow map. Try to debug it and make sure which steps are correct and you will quickly identify the problem.

Edited by michalferko

##### Share on other sites

Thanks for your answer, the problem is fixed now, I just compared wrong things.

1. 1
Rutin
26
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 21
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631763
• Total Posts
3002190
×