Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: How can I convert a 3D model to a depth map?

  1. #1
    Newbie Newbie
    Join Date
    Jul 2013
    Posts
    1

    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?

  2. #2
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    490
    Quote Originally Posted by prerna1 View Post
    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.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2013
    Posts
    25
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •