#### Archived

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

# Depth buffer does not depth bufferize

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

## Recommended Posts

Hi! I have a problem. Even if I enable depth buffering, a polygon(pFront) I draw is hidden by another polygon(pBack) if I draw pFront first and pBack second. I enable depth buffering this way:
if( FAILED(m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE)) )
return E_FAIL;
I use D3DFVF_XYZ to render the polygons. I have a RADEON 9700 PRO, if that could matter. I test for compatibility between render surface and the depth buffer with CheckDepthStencilFormat. Thanks for your help! ph0ng^_^wh0ng

##### Share on other sites
Hi,

I assume dx8 or dx9:

Have you indicated, in present parameters, during device creation, that you want a depth buffer? Also, have you set the format of the depth buffer (in pres parms also) to one that your card supports?

EDIT:
And when all other checks are done, don't forget to clear the depth buffer to 1.0 between frames! Not doing so may result in weird renderings sometimes...

[edited by - Nik02 on September 25, 2003 1:44:07 PM]

##### Share on other sites

Yes, I set these D3DPRESENT_PARAMETERS fields correctly.

I happened to set the near clip plane at 0.f. Now I set it at 1.f and it''s ok. Anyone knows why?

ph0ng^_^wh0ng

##### Share on other sites
Quote from the Red Book (the Red Book is for OpenGL but I''m 100% sure it applies to D3D too) :

Depth-buffer precision is affected by the values specified for znear and zfar. The greater the ratio of zfar to znear is, the less effective the depth buffer will be at distinguishing between surfaces that are near each other. If

r = ( far / near)

roughly log (2) r bits of depth buffer precision are lost. Because r approaches infinity as znear approaches zero, you should never set znear to zero.

##### Share on other sites
quote:
Quote from the Red Book (the Red Book is for OpenGL but I'm 100% sure it applies to D3D too) :

Depth-buffer precision is affected by the values specified for znear and zfar. The greater the ratio of zfar to znear is, the less effective the depth buffer will be at distinguishing between surfaces that are near each other. If

r = ( far / near)

roughly log (2) r bits of depth buffer precision are lost. Because r approaches infinity as znear approaches zero, you should never set znear to zero.

Correct. It works exactly same in d3d.

[edited by - Nik02 on September 25, 2003 2:06:26 PM]

##### Share on other sites
Boy there should be a Red Book for D3D... SDK documentation hardly gives any DETAILED informations...

Thank you both!

ph0ng^_^wh0ng

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 11
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633718
• Total Posts
3013522
×