Skip to main content
GameDev.net gamedev.net
🔒 Locked

z-buffer not working...

Started by marlboro Jan 5, 2005 at 10:54 AM 1 replies 600+ views
Original Post
marlboro
marlboro
Hi, I've got a z-buffer issue happening that I can't seem to get fixed. I feel sure it's simply a setup issue, so I'll try and layout the scenario. First, I am placing two quads in world space at 0,0,0 and 0.5,0.5,0.5. The second quad is being draw last (on purpose), but it should be occluded by the first quad. This is not happening! Quad two displays on top of quad one. If I rotate quad one, it will jump in front of or behind quad two. The important code snips are as follows: d3dpp.EnableAutoDepthStencil = true; d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE ); D3DXMatrixPerspectiveFovLH(..., 1.57f, 1.33f, 0.0f, 1.0f); Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, m_rgbaClear, 1.0f, 0); Thanks, marlboro
Namethatnobodyelsetook
Namethatnobodyelsetook
Is that a near of 0 and a far of 1? Near cannot be 0, and should be as large as possible. Consider values like 5, 1000. Adjust your mesh scale and position accordingly too.
marlboro
marlboro
Thank you! You confirmed my suspicion that I had something setup wrong. I changed the zn and zf parameters of D3DXMatrixPerspectiveFovLH(...) to 0.1f and 1000.0f and everything works grand.

Thanks again!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.