Archived

This topic is now archived and is closed to further replies.

Electron

read (use) the information in the depth buffer?

Recommended Posts

Shadowmaps, for example, uses the depth buffer to tell wether or not a pixel is shadowed. How can you get the information on the depth buffer in a way you can actually *use* it? I know i can use glReadPixels to obtain the data from the depth buffer, but to copy the entire buffer to a list of floats and then use it is, well.. not so fast... I discovered that i can make a *fake* depth buffer using fog and the color buffer. I can then use glCopyTexImage2D to obtain the data in a nice texture. The problem is that it''s much less detailed. If you want to *manually* make a shadowmap, how do you do to get good information on the depth buffer information? Electron

"The truth can be changed simply by the way you accept it."


Share this post


Link to post
Share on other sites
You can use the a pbuffer to render the depth into an offscreen buffer and use this as your texture, it should be faster than copying it from back to your main memory and then uploading to texture. The ARB_depth_texture and ARB_shadow extensions should also help do hardware shadow mapping. As far as faking a depth texture (this gives u more accurate depth, since the depthBuffer grows nonlinearly) they mention a way to render a depth buffer in the color buffer using 1d texture and and distance to the near plane (page 10, first slide). I also wrote avertex shader that shads color based on distance of near plane to vertex, but i found that my scene had to be quite tesellated for it to look right (i'm sure i could do better now but i think that was one of the first vp i worte).


http://www.cs.utk.edu/~huangj/CS594F01/GDC2K_ogl_shadowmap_handout.pdf

"How can you get the information on the depth buffer in a way you can actually *use* it? "

I think you have to keep all your computations on the card; Fragment programs and the extensions mentioned above can help, but if you want to maniulate the depth buffer on the cpu side, then that would involve a copy to main memory(slow).


[edited by - _walrus on May 5, 2003 8:41:57 AM]

Share this post


Link to post
Share on other sites