Jump to content
  • Advertisement
Sign in to follow this  
Zische

problem with z-test

This topic is 4813 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

i have set the following render states: m_pd3dDevice->SetRenderState(D3DRS_ZENABLE, TRUE); m_pd3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); i clear the depth buffer with 1.0f. when i render two quads (one at z=5.0, the other at z=6.5), there seems to be no depth test, because the far quad is rendered on top of the near quad. in my confusion i set the render state to this: m_pd3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL); it looks the same. that means the depth values of the quads are 1.0f.... when i clear the depth buffer with 0.0f and set the render state m_pd3dDevice->SetRenderState(D3DRS_ZFUNC, D3DCMP_GREATER), the near quad overlaps the far quad. this looks right but it can't be, because the z-values of the vertices are not at 1.0f in clipping space. the projection matrix is set by D3DXMatrixPerspectiveFovLH(&m_ProjectionMatrix, D3DXToRadian( 45.0f ), (float)Width/(float)Height, 0.0001f, 100000.0f); m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &m_ProjectionMatrix ); the near and far planes of the viewport are the same.

Share this post


Link to post
Share on other sites
Advertisement
i have found the mistake in my code...
the near plane of the viewport must be 0.0f and the far plane 1.0f. now it tests correctly.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!