Jump to content
  • Advertisement
Sign in to follow this  
Lio

XNA CullMode and DepthBuffer

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

Quick question. Ive set up a qube out of 8 vertices and 36 indices using DrawUserIndexedPrimitives(); I appears fine if i turn on ClockWise CullMode. But if i set it to None its as i can see the backside of some of the vertices through the qube. Ive set the indices so that they are clockwise. I clear the depth buffer with ClearOptions.DepthBuffer before each frame is drawn. Can someone englighten me? I cant remember to have had this problem either in Managed DX. Shouldnt clearing the depthbuffer sort this, even with CullMode set to None, so that vertices that are further away is hidden behind closer objects etc. Thank you for any reply. edit: Can my effect file play any part?

Share this post


Link to post
Share on other sites
Advertisement
Have you enabled z-writes and z-culling? You should have the effect states set like this:


ZWriteEnable = true;
ZEnable = true;


[Edited by - MJP on July 2, 2008 8:24:47 AM]

Share this post


Link to post
Share on other sites

Providing it doesn't do anything really crazy, your effect shouldn't have much to do with this. Like MJP said, make sure your ZBuffer is enabled first. If that's set up correctly, another common cause for this behavior is using 0.0f for the near clipping plane of your projection matrix. If that's the case, try changing it to 1.0f (or as big a number that works for you) to fix it.

For more information, this article would be a good read.

Share this post


Link to post
Share on other sites
Thanks alot guys.

I had it work by setting:
device.RenderState.DepthBufferEnable = true;

And thanks for the article Remigius, ive already stubled upon in earlier and its a very nice explenation of the Zbuffer and Z fighting.

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!