Meaning at this point the projection has already been done. This article gives us the projection matrix used by OpenGL, and the factor that affect the z-coordinate of a point is the row:
[ 0 0 -(f+n)/(f-n) -2fn/(f-n) ]
Note, this matrix is computed to make the ‘pyramidal’ frustum to a unit cube. Meaning the z-coordinate has also been mapped to [0,1] after this matrix is applied.
Then, the author in the depth value precision chapter tells us: These z-values in view space can be any values between frustum’s near and far plane and we need some way to transform them to [0,1]. The question is why at this point, when we had already mapped it while applying the projection matrix.
Also, he says:
a linear depth buffer like this:
F_depth=z-near/(far-near)
is never used, for correct projection properties a non-linear depth equation is used:
F_depth= (1/z- 1/near)/(1/far - 1/near)
But, as we have seen, z is mapped within range using:
[ 0 0 -(f+n)/(f-n) -2fn/(f-n) ]
Which appears to be linear.
All these contradicting statements are making me really confused on when is the depth for fragments calculated and compared,and what is the equation actually used to compute this. In my understanding nothing more for depth should be calculated after the OpenGL projection matrix is applied, but after reading this I’m really confused. Any clarifications?