[SOLVED] Invert colors with the help of BlendState

Is it possible to use a custom BlendState to invert the colors of a texture?

quick reply, don’t have time to try it out right now, but yes it should work

Check out the documentation of blendstates and functions, i think there is something like 1-x as a predefined function

Edit:
Okay I found a way to do it:

bsInverter = new BlendState()
{
ColorSourceBlend = Blend.Zero,
ColorDestinationBlend = Blend.InverseSourceColor,
};

GraphicsDevice.Clear(Color.White);
spriteBatch.Begin(SpriteSortMode.Deferred, bsInverter);
spriteBatch.Draw(sprImage, Vector2.Zero, Color.White);
spriteBatch.End();

The destination color (white) is multiplied with the inverse of the source color (sprite to invert).

2 Likes