I am working on a game in XNA 4.0 that has been entirely in 3D so far but now I want to incorporate a HUD.

I have tried doing a simple test using spriteBatch as such:

spriteBatch.Draw(Player.Texture, new Rectangle(0, GameConstants.GraphicsDevice.Viewport.Height - 50, 50, 50), Color.White);

This works fine and the test texture shows as a rectangle in the correct position but the 3d World behind seems to have a sort of "haze" over the top which looks like the drawn "Player.Texture" has been put all over the viewport but at an alpha of like 0.1f.

I googled around and have a reset() function to change some of the GraphicsDevice properties back after drawing the SpriteBatch but nothing has changed and I haven't seen anyone else with this problem.

I thought it would be that SpriteBatch changes the blendmode to additive but in my reset() function I set the blendmode to opaque so I have no idea where this strange effect is coming from, it looks like I've ran some post-processing on the whole scene.

If I change the Player.Texture that is drawn in the SpriteBatch then the "haze" changes to look like the new texture so it is definitely to do with that.

Are there any other GraphicsDevice propterties I should check to change back?


Okay, I have just realised the "haze" over the top is from the SkySphere texture, I am using the MSDN skysphere shader from this tutorial.

So when I comment out the SkySphere code, the spritebatch and 3d drawing looks completely fine, but this leaves me with the problem that I can't have a SkySphere anymore.

Is there some reason why the skysphere is sort of drawn over the scene translucently rather than behind the 3D after I use a SpriteBatch? As I said before, it kind of looks like additive blending.

Below are 2 screenshots, the top is with spritebatch and no skysphere, below is with spritebatch and skysphere where I am having problems. I have cropped the images down to save upload (my internet is pretty slow at the moment) and I've changed the area of the scene in the 2nd image to show more clearly what it looks like. As I move around the scene with the camera the "haze" overlay stays in the same place exactly as how the SkySphere works, as in not taking into account the world matrix.

Screenshot 1 Screenshot 2

  • \$\begingroup\$ A screenshot would help. \$\endgroup\$
    – Tetrad
    Jan 8, 2012 at 2:54
  • \$\begingroup\$ Sorry, I've added links to screenshots now but I can only have 2 hyperlinks so there are only 2 images, also I've narrowed the problem down to the SkySphere shader. Thanks. \$\endgroup\$
    – user319256
    Jan 8, 2012 at 3:15
  • \$\begingroup\$ @user319256 - I know you said you tried changing some back, but have you taken a look at blogs.msdn.com/b/shawnhar/archive/2010/06/18/…? Also, did you draw 3D first, or 2D first? This can affect where you should place your reset function. \$\endgroup\$
    – DMan
    Jan 8, 2012 at 4:04
  • 3
    \$\begingroup\$ My psychic powers say that your reset function clears the depth buffer, and you're drawing like this : World, Hud, Reset, Sky. \$\endgroup\$
    – Blecki
    Jan 8, 2012 at 16:08
  • \$\begingroup\$ Ah yes, I didn't think about the order in which the skysphere and 3d and spritebatch was rendered so even though I reset the settings linked after drawing the spritebatch the skysphere then set some other values which needed to be reset. Thanks for the help! \$\endgroup\$
    – user319256
    Jan 8, 2012 at 16:28

1 Answer 1


It looks like you're drawing your skysphere after your HUD. You should draw the skysphere after drawing the world (the depth buffer will save you a lot of overdraw), and draw the hud last.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .