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 5 of 5

Thread: Visualizing Orthographic Depth Buffer

  1. #1
    Newbie Newbie
    Join Date
    Nov 2015
    Posts
    5

    Visualizing Orthographic Depth Buffer

    Hello,

    I am currently implementing shadow mapping in OpenGL.
    It is working, so that's great. However, for fun, I wanted to visualize my depth buffer.
    Now, when I use perspektive projection for the light and use the interpolation algorithm I get a nice depth map.
    However, I simply can't get it to work for my standard orthographic projection. The whole scene is just one single color.
    I'm assuming I'm missing an interpolation step, like for perspective projection. But I can't seem to figure it out.

    Does anybody know what's missing?

    Current Depth Maps can be found here: imgur.com/a/bkdPt
    (Forum wont accept my images)

    Best,
    Marc

  2. #2
    Intern Contributor
    Join Date
    Feb 2016
    Posts
    64
    Check the near and far plane values for your orthographic projection, it looks like there's not enough precision for the depth buffer so there's only one depth value for the whole terrain.

  3. #3
    Newbie Newbie
    Join Date
    Nov 2015
    Posts
    5
    Ok, so my near plane is at 0.1f and far at 2.0f

    But as I said before, my shadowmapping actually works. So the values generated seem to be fine.
    Its just when visualizing it, the depth values seem to be too small to be converted to differentiating colour values.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,000
    Quote Originally Posted by Geoeoeo View Post
    But as I said before, my shadowmapping actually works. So the values generated seem to be fine.
    Its just when visualizing it, the depth values seem to be too small to be converted to differentiating colour values.
    The depth buffer is probably 24-bit. If your entire scene only used 1/256th of the depth range, you'd still have 16 significant bits, which would be perfectly adequate for shadow mapping but converting the depth values to 8-bit grey levels would result in the entire scene using the same value.

    For a perspective projection, this typically doesn't matter, because most of the depth range is used for values close to the near plane. You can set the far plane to infinity without significantly affecting the depth values used for most of the scene. So long as most of the scene is relatively close to the near plane, you'll get a wide range of depth values.

    If you can figure out approximately the extent of the scene, map depth values to grey levels accordingly. If you can't do that, use only the least significant bits of the depth values so that the mapping repeats.

  5. #5
    Newbie Newbie
    Join Date
    Nov 2015
    Posts
    5
    Thanks a lot for that explanation!

    I knew it had to be something with my buffers

Posting Permissions

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