Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

XNA seems to be ignoring my Z coordinate. There is no form of Z-culling at all it seems. How come? I am doing an orthographic projection, and clearing the depth stencil buffer for every draw-call.

My elements rendered are quads with textures, through instancing. These elements have 1 difference in the Z-coordinate in order to eachother, based on theri Z-index.

share|improve this question
Code would help. – The Communist Duck Jun 16 '11 at 12:26
A better description of what you Are seeing would also help. – James Jun 16 '11 at 17:45
up vote 4 down vote accepted

What have you set GraphicsDevice.DepthStencilState to? It should be DepthStencilState.Default to both read and write the depth buffer.

Are the differences in the Z-coordinate within the available precision of the Z-buffer? Are you getting Z-fighting? Are your near and far planes too far apart? (The further apart they are, the less precision you have.)

Do your textures make use of transparency? In that case you must either use alpha-testing (to skip transparent pixels) or you must Z-sort your objects and not use the Z-buffer. You can't use the Z-buffer for transparent objects.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.