A W-Friendly Projection Matrix
Microsoft Direct3D can use the w-component of a vertex that has been transformed by the world, view, and projection matrices to perform depth-based calculations in depth-buffer or fog effects. Computations such as these require that a projection matrix normalize w to be equivalent to world-space z. In short, if a projection matrix includes a (3,4) coefficient that is not 1, you must scale all of the coefficients by the inverse of the (3,4) coefficient to make a proper matrix. If you do not provide a compliant matrix, fog effects and depth buffering are not applied correctly. The projection matrix recommended in What Is the Projection Transformation? is compliant with w-based calculations.
The following illustration shows a noncompliant projection matrix, and the same matrix scaled so that eye-relative fog is enabled.
In the preceding matrices, all variables are assumed to be nonzero. For more information about eye-relative fog, see Eye-Relative vs. Z-Based Depth. For more information about w-based depth buffering, see Depth Buffers.
Note: Direct3D uses the currently set projection matrix in its w-based depth calculations. As a result, applications must set a compliant projection matrix to receive the desired w-based features, even if they do not use the Direct3D transformation pipeline.