Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Which kinds of culling and clipping does XNA do for me as default, and which kinds does it not?

Z-culling? Backface culling? etc.

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

Z-culling (culls pixels that are behind already-drawn pixels in the Z-buffer) and back-face culling (culls triangles that are facing away from the camera) are handled by the DepthStencilState and RasterizerState respectively. These are state objects.

They are also the names of properties where you can set those state objects on the GraphicsDevice (MSDN).

The default values are:

DepthStencilState.Default (MSDN) which is set up to both read and write from the depth buffer.

RasterizerState.CullCounterClockwise (MSDN) which is set up to cull triangles where the vertices are counter-clockwise.

There are other built-in states available on the state objects, see the static members for each state object (MSDN: DepthStencilState, RasterizerState). Additionally you can create your own state objects that further customise the behaviour.


XNA itself does not provide any built-in culling mechanisms, except exposing those provided by the graphics device. These include Z-culling and backface-culling. You could also argue that the stencil buffer, scissor tests, and the viewport are also kinds of culling.

XNA does, however, provide some useful classes for adding your own, more advanced, object-level culling mechanisms. For example BoundingFrustum provides intersection tests to allow you to determine what objects (usually represented by a BoundingBox or BoundingSphere) are visible in your 3D camera.

This question and answer provide some useful information about how to decide where culling is appropriate.

share|improve this answer
    
+1 for another full and well explained answer. –  Jonathan Connell Jun 15 '11 at 7:46
add comment

The default value is CullMode.CounterClockwise. Options are:

  • CullClockwiseFace - Cull back faces with clockwise vertices.
  • CullCounterClockwiseFace - Cull back faces with counterclockwise vertices.
  • None - Do not cull back faces.

http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.cullmode.aspx

share|improve this answer
add comment

Your Answer

 
discard

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.