Jump to content
  • Advertisement

Archived

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

ph0ngwh0ng

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.

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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Thanks a lot for answering!

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 this post


Link to post
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 this post


Link to post
Share on other sites
quote:
Original post by Prosper/LOADED
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 this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!