I am interested in using a non-standard depth buffer to deal with a large dynamic range in distance in a single scene. The best solution out there seems to be using reversed-z buffers with floating point depth values. It is great because there is no slowdown because it can still use the hardware depth pipeline (unlike for things like log or linear depths).
The main trick is to put zNear= the far distance and zFar = the nearer distance.
OpenGL is fine with this – does Panda3d object? Even if it does I assume a workaround would not be too much work but there are additional steps as well.
There is a really good overview here:
The author lists 5 key steps to make it work:
1) Depth buffer must use 0 to 1 not -1 to+1 (glClipControl does this)
2) Float 32 bit z-buffer – takes advantage of float/exp representation to preserve resolution near 0
3) Depth buffer Clear to 0 (far)
4) Flip depth comparison to greater than
5) Special perspective matrix (because the scene is mirror-reversed otherwise)
There are a few interesting articles showing just how effective this is in practice. Quite simply its amazing and takes you from about 4 decs depth precision to over 7 decades (i.e. better than 10 million dynamic range).
Are there any road blocks to doing this in Panda? For example, I didn’t see how glClipControl was exposed to the user in Panda. I have also struggled a bit convincing the renderer to use a 32 bit float (not fixed) depth buffer. The last awkward part seemed to be the need to generate your own perspective matrix and thus forgo the nice automatically made matrix features of Panda.