I'm having difficulty figuring how to do something in XNA.
I have something like this:
public void Draw()
{
spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend);
DrawFirstObject(); // Depth = 0.5f
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.Additive);
DrawSecondObject(); // Depth = 0.2f
spriteBatch.End();
}
Basically I need to have 2 different spritebatch begin calls one with AlphaBlend and one with Additive BlendState. But the problem is when I make this the drawn objects from the second call are always drawn on top of the first ones instead behind them where they need to be. I can't reformat my code so the second call is on the top and I need the keep the depth order. So I would be thankful if you have any suggestion.
spriteBatch.Begin()
dynamically if you encounter a state change. It's probably possible to optimize this sorting procedure for minimal state changes but that would depend on your scene. – Nico Schertler