PDA

View Full Version : Visualizing Orthographic Depth Buffer



Geoeoeo
02-27-2016, 04:44 AM
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

Spoops
02-27-2016, 08:05 AM
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.

Geoeoeo
02-28-2016, 05:00 AM
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.

GClements
02-28-2016, 07:53 AM
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.

Geoeoeo
03-04-2016, 01:38 PM
Thanks a lot for that explanation!

I knew it had to be something with my buffers :p