Precondition: I read this question/answer about using shaders, or spritebatch, to render and mark a sprite.

I need to do something like that. I also have a 2D lighting PoC which I need to write. The way it will work will basically be something like:

  • Draw all the sprites
  • Draw lighting gradients to create a lighting texture
  • Multiply/add the lighting texture to achieve different effects

(I use multiple passes of add/multiply the lighting texture to achieve different effects.)

My question is really about a generalization: can I say with certainty that pixel shaders are always faster than adding/multiplying textures to the SpriteBatch? Or that adding/multiplying is always faster? Or if it's not generalizable, how do I decide which approach to take, given that I can probably code either of them?

(If it matters, I'm using MonoGame 3.0 beta for Windows games)

  • \$\begingroup\$ What do you mean by "adding/multiplying textures to the SpriteBatch"? \$\endgroup\$ Commented Dec 10, 2012 at 8:12
  • \$\begingroup\$ @AndrewRussell this might be naive, since I haven't actually tried this. Normal operation = copy pixels to target texture. Add = add the source pixel RGBA values to the target pixel. Multiply = multiply target values by source values. Think Photoshop layer modes. \$\endgroup\$
    – ashes999
    Commented Dec 10, 2012 at 11:59
  • \$\begingroup\$ Ok, then I think your question is basically: Which is faster? Doing multi-pass rendering with different blend modes (see BlendState)? Or rendering a single pass with multi-texturing? (I don't know, but I'd guess the latter.) \$\endgroup\$ Commented Dec 10, 2012 at 15:25
  • \$\begingroup\$ @AndrewRussell that's my guess too. If someone knows, or if I figure it out, that information will go into an answer for this question. \$\endgroup\$
    – ashes999
    Commented Dec 10, 2012 at 18:19

1 Answer 1


if i understood correctely, you are asking about what is faster, mix colors in pixel shaders or mix colors using blend states ?

In general case, using Blender States should be faster cause Video Boards normally have specifically dedicated piece of harware to perform this operation. (In this aproach you can also use the pixel shader to perform other funcy stuff in the texture you read)

But, for example, if you need to perform 3 pass to get the result you want (each one with a different blend state), probably mixing the color in just one pass in one pixel shader would be faster.

To be honest (assuming you are targeting PC), unless you are doing MASSIVE color mixing, both approach wont be a bottleneck in your application.

just to clarify one last thing. Spritebatch is just an easy to let you handle textures and text easily (and also performatic way), behind the curtains, it is actually drawing a full screen quad, using a shader ......


You must log in to answer this question.

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