Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)

share|improve this question
What do you mean by "adding/multiplying textures to the SpriteBatch"? – Andrew Russell Dec 10 '12 at 8:12
@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. – ashes999 Dec 10 '12 at 11:59
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.) – Andrew Russell Dec 10 '12 at 15:25
@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. – ashes999 Dec 10 '12 at 18:19

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 ......

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.