Debugging shadow maps

Hoping someone can help.

I am following this tutorial.

I can get the code as presented working, but when I integrate what I think are the same concepts into my own framework, it doesn’t work. I do not get any errors detectable with glGetError(), just don’t get the right shadowing.

I have the shadow depth data stored in a depth texture per the tutorial, created with:

I guess the first debug step is the check the data in the texture… but I don’t see how to do this. I am using an RGBA display - is there a way to project the data in the depth texture onto the screen so I can get some idea where the problem is? or any helpful debug utilities to read the depth texture & see if I actually have sensible data values in it?


i had the same issu once.
make a quad inside your 3d world and texture it with the shadow map … thats the first hint to see if the texture is holding the right data.


Thanks … still need some help tho… how do I map from the depth texture (single value, float) into an RGB texture (e.g. 8 bits per channel) or similar that I can display?

In case anyone knows a better way - I am debugging this the brute force way - copying the data out of the depth buffer with glReadPixels, remapping to a 0.0 to 1.0 range, then creating a colour texture from the result using glTexImage2D. Any easier ways of doing this appreciated.