#### Archived

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

# parallel projection z-buffer problem.

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

## 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 on other sites
How did you set your parallel/orthographic projection matrix ?

Is it W friendly ?

Is it ensuring that clip space Z and W are in the correct range ?

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

##### 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 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           00    2/h  0           00    0    1/(zf-zf)   00    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
www.creative-asylum.com

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 29
• 41
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631741
• Total Posts
3001976
×