Problems with ZBuffer and Projection matrix

Hi DirectX experts.

I have found a weird problem.
The ZBuffer is behaving strange when i change the projection matrix.
I experienced these problems while building my engine, so i used one of the SDK samples to reproduce it. Here is my code (Its pascal):


Answer this question

Problems with ZBuffer and Projection matrix

  • Ben Hall (UK)

    Be sure that DirectX is not clearing the Z buffer without you're help.

    The projection matrix, along with the view and world matrix, is used to compute transformed vertex position and thus final pixel Z value. The Z value range is given by the projection matrix according to its construction parameters (near, far, fov, width, ...). This range is used for clipping and enable comparing Z values within its limits. Changing one of this values, and especialy swaping from orthogonal to perspective projection, changes Z value range. It means that Z values obtained using different projection matrices cannot be compared.


  • Problems with ZBuffer and Projection matrix