This topic is now archived and is closed to further replies.

parallel projection z-buffer problem.

This topic is 5434 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When using parallel projection, objects that are farther away get rendered on top of objects closer to the camera (the last one drawn gets on top). This problem only occurs when using this projection and not in perspective projection. Does anyone have any advice?

Share this post

Link to post
Share on other sites

D3DXMATRIX matProjx(
0.025f, 0, 0, 0,
0, 0.025f, 0, 0,
0, 0, 0, 0,
0, 0, 1, 1.0f);
m_pD3DDevice->SetTransform(D3DTS_PROJECTION, &matProjx);

I don''t know what W friendly is (3d newbie). :/

Share this post

Link to post
Share on other sites

Ah - no Z output and no Z range. Use D3DXMatrixOrthoLH or the following matrix (which is exactly what it generates):

2/w 0 0 0
0 2/h 0 0
0 0 1/(zf-zf) 0
0 0 zn/(zn-zf) 1

w & h = width & height of surface, you can use your 0.025 if you want - they just affect how x and y get scaled.

The important parts though are specifying the minimum and maximum Z values *in camera space* used for clipping AND the Z buffer. zn is the near clipping plane, zf is the far clipping plane. Feed in the same values you do for your perspective. Remember not to set zn or zf to 0.

[See the other recent post on exactly what the values mean - titled something like "FOV"]

Simon O''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites