Hi all.
I’m trying to do the shadow/light map for my OpenGL scene using render to texture…
What function/code to get the grayscale depth render? I bump into it last time - at that moment I’m still learning on how to set up OpenGL. Can’t find it now. Maybe I’m googling for with a wrong keywords.
Please help me… Thank you.
You’re using the ARB_depth_texture/ARB_shadow extensions, and you want to view the depthmap for debugging purposes?
You can read all the gory details in the registry:
http://www.opengl.org/registry/specs/ARB/depth_texture.txt
http://www.opengl.org/registry/specs/ARB/shadow.txt
Or you could break out the spec (equally gory), since these were made part of the core in version 1.4:
http://www.opengl.org/documentation/specs/
(See the table in section 3.8.4, p. 168.)
I think you’re basically looking for something like this:
...
glTexParameteri(target, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE);
glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_NONE);
...
Then you should be able to use your depthmap as a greyscale texture.
Hope it helps.
Also be aware that sometimes depthmaps can appear to be a solid color, due to the way depth values are mapped into texture (screen) space and the overall z range of your scene w.r.t. the camera (light source). You really need a pretty quick change in z to discern your shapes sometimes. Kinda freaked me out the first time…
looking on it… thanks caveman…