Public Group

# XNA CullMode and DepthBuffer

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

## 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 on other sites
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 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.

##### 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.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 31
• 16
• 11
• 10
• ### Forum Statistics

• Total Topics
634122
• Total Posts
3015617
×