I was reading an old post from Steve Baker about Learning to Love your Z-Buffer (https://www.sjbaker.org/steve/omniv/love_your_z_buffer.html) where he explains that z buffer integer value is calculated in the following way:
z_buffer_value = (1 << N) * ( a + b / z)
where
N = number of bits of Z precision
a = zFar / (zFar - zNear)
b = zFar * zNear / ( zNear - zFar )
z = distance from the eye to the object
and z_buffer_value js an integer value.
I have 2 questions:
(1) What are the steps to get that equation?
(2) If you create your depth buffer with a floating point format. Is Z distance from the eye to the camera stored directly instead?