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

I have a model which draws correctly in XNA4.

However if I try to add a background image (or any sprite), the rendering of my model is messed up. There are two problems with the rendering

  1. model is partially transparent
  2. hidden surfaces are visible.

This is the 'problem' rendering Above is the 'problem' rendering (the cyan coloured cockpit cover is visible through the bottom of the ship)

This is how the rendering *should* look This is how the rendering should look

share|improve this question

The problem is caused by the SpriteBatch.Begin() changing some of the rendering states.

This problem is solved in XNA 3.1 and earlier by using the SaveState flag (see this answer).

However in XNA 4.0+ you need to restore the state yourself.

Insert the following code after your sprite drawing but before your model drawing (or 3D primitive drawing)

GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;

Information based on original article by Shawn Hargreaves

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.