How can I convert a 3D model to a depth map?
What I am trying to do is perhaps similar to generating a Z-buffer representation. However, how do I do this?
I can use glReadPixels(...) to get the z-depth data, however, how do I render this z-depth data into a depth image?
With glTexImage2D() or (if you're writing into an existing texture) glTexSubImage2D(). Or you could skip the glReadPixels() step altogether and use glCopyTexImage2D() or glCopyTexSubImage2D() to copy data directly from the depth buffer to a texture.
Originally Posted by prerna1
I think what you are looking for is the first stage of a shadow mapping setup.
(i) Generate an FBO that is setup for depth rendering only.
(ii) In the render loop, activate the depth FBO and render the models. This will create the depth map.
(iii) Deactivate the FBO.
(v) Apply the texture generated by the FBO to a screen aligned quad. This will display the depth map.