depth buffer growth function

Hi, i’m just doing some work with the depth buffer, and i know it doesn’t grow linearly (as we aproach the far clipping plane, the accuracy decreases) I’m just wondering of this accuracy decreases as we move father back in the depth buffer (z-value approaches 1.0). Does anybody know the equations that represents this decrease? thanks

If setting up your projection matrix with glFrustum, for example, your ndc z
(after perspective divide) would be:

Z_ndc = (zfar+znear)/(zfar-znear) + 2zfarznear/((zfar-znear)*z_eye)

I was interested in a similiar matter yesterday. You might find this thread interesting:… .algorithms

The above function visually: