Search code examples
c#xnamonogame

Unwanted color blending


Im drawing two rectangles. One is orange, and the other is pink.

 spriteBatch.Draw(texture, mainRect, mainColor_Current);
 spriteBatch.Draw(texture, goalRect, goalColor_Current);

They use the same texture, only with different colors. Somehow i end up with this.
The white isn't its own square, its just the half of the pink square that overlaps with the orange square.

Why is this? And how do i fix it?

(also, the texture I'm using is a 1x1 white pixel with no alpha channel).


Solution

  • Turns out i needed to pass BlendState.Opaque into SpriteBatch.Begin().

    spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.Opaque);