PDA

View Full Version : Debugging shadow maps



2Wheels
06-09-2013, 10:44 AM
Hoping someone can help.

I am following this tutorial. http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/

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:
glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16,
(BUint)x, (BUint)y, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);

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?

uwi2k2
06-09-2013, 12:53 PM
hi,

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.

cu
uwi

2Wheels
06-09-2013, 01:10 PM
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?

2Wheels
06-11-2013, 09:07 AM
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.