A common scenario is using SpriteBatch to perform some 2D rendering in a game, even if the game is primarily 3D. Examples include menus, HUDs, and any number of other things. The problem people find is that their 3D rendering no longer works properly after using SpriteBatch often going all black. The cause is that SpriteBatch alters some render states in order to render properly. More information on what states are affected can be found on Shawn Hargreave's blog and in the MSDN SpriteBatch documentation.
There are two solutions to this issue. The first, as suggestion on Shawn's blog, is to simply restore the render states needed for your 3D rendering. By and large you will only need to change a few, but this all depends on what your 3D rendering requires. This is by far the most performant approach, but is not always the easiest for beginners since they may not understand which render states are needed for their 3D rendering.
The second solution is to use SaveStateMode.SaveState in your call to SpriteBatch.Begin. This solution works great, but there is a catch to it. Specifying SaveStateMode.SaveState will cause the SpriteBatch to save and restore all render states; not just those changed by the SpriteBatch. This results in the saving and restoring of redundant render states and can be costly.
So in summary, feel free to use SaveStateMode.SaveState in your SpriteBatch calls in order to get your 3D rendering working properly. Just keep in mind that there is a performance hit to this so if your rendering code because slower, you may want to switch over to manually resetting just the render states you need.
Jim Perry - Microsoft XNA MVP
If people spent a minute
searching the forums and reading
the FAQs before posting I'd be out of a job.
Got some XNA Game Studio/XNA Framework development info to share with the community? Put it on the
XNA Wiki.
Please mark posts as Answers or Good Feedback when appropriate.