Is it "slightly" faster to draw sprites that don't have alpha versus ones that do?

Hi guys, so yeah, that’s basically the question, I am curious to know if someone already tested if the engine optimizes drawing without alpha, thus, making it “slightly” faster. I would expect that the color interpolation math would be skipped then.

Offcourse, I don’t expect that “slightly” to amount to much, but for projects where you’d use quite a lot of small tiles to do complex compositions, it might matter in the decision of having alpha or not, so I’d like to know whether I should consider it.


1 Like

Hello. Drawing as Opaque is faster than Alpha blend (relatively often can yield considerable performance gain). Alpha blend is negligibly faster than Nonpremultiplied (to point you can ignore it on modern hw). Difference between Opaque and Alpha blend is that in case of Opaque destination color/alpha doesn’t matter. So if you are using sprites without transparency make sure that your blend state is actually Opaque.


Ah, so you mean I can have one or the other, not both.

For instance, I know I do need transparency for some tiles, but it won’t make a difference unless I switch to Opaque, correct?

Yep, but depending on what you render you can batch by required blend states.

1 Like

Clear, thanks! :slight_smile:

1 Like

Something else to consider… overdraw is a thing. When you have rectangular sprites with transparency, those transparent pixels are still processed during a render pass.

I watched some interesting talk for some game (that I can’t remember) where they were running into performance problems and overdraw was a part of the issue. They resolved it by calculating bounding geometry for a sprite, then texture mapped and rendered to that instead. This significantly cut down on the number of pixels that needed to be rendered for any given sprite.

It was pretty interesting, I’ll see if I can dig it up, but it was a while ago so I’m not even sure what to google for :smiley:

To your original concern though…

I’m a big advocate of “optimize later” (within reason, of course). This is definitely something that you can address later in your project, if performance starts to become an issue. The only thing you might want to concern yourself with up front is how you want to decouple your rendering engine so that you can easily swap to another, more performant method later :slight_smile:

1 Like

Yeah, basically if you have part of sprite that is fully transparent it is often worth it to create tight bounding geometry. Especially for 2d games where fill rate is main performance concern. Few extra vertices are generally way cheaper, if you have lot of transparent particles it is generally worth investing into making ngons as their bounding geometry rather than quads. At same time if you are not targeting mobile phones or inferior hardware it is kinda unlikely for most of the indie 2d games to run into performance issue even when using most naive rendering techniques.


I can’t find the video… though there’s lots of resources talking about overdraw performance mitigation haha.

It was for some game that was a 2D platformer that had something to do with music… maybe? Internet points to anybody who can find the video…! :smiley:

Well, I am indeed at that “later” stage in the game. Up until now, I am rather unconcerned regarding performance. For instance, the scene below features 2k characters and it runs smoothly at 60fps. On my laptop I can bump it up to 10k until I start seeing some decay in performance. And I will never feature more than 20-30 characters per screen at any time.

However, I need to procedurally generate city scenery. I’ll have to generate buildings with varying definition parameters that will themselves generate walls, windows, doors and other self decorations. And, offcourse, that means overdraw. A LOT of it. Here is a very simple example.

This is a simple wall rendering (composition 1), but you can easy see I do an overdraw of over 60% of the original. So, the decision could be to make tiles 2, 3, 6, 7, 8 and 9 opaque AND include complementary brick pixels, however, that would not be flexible enough to generate, say, composition 2, at the right of the figure above.

Indeed, I am not really concerned with performance so far, I do have a good feeling about it, but once you start to implement procedural graphics composition, things can quickly get out of hand once you instantiate a building that triggers a lot of its own draws for all its component elements.

Thanks for the input! I’ll look for that video. :smiley:

Actually I suggest looking for AAA when it comes to performance optimization, mention of this is for example in presentation from Avalanche studio about Apex Engine (Just Cause), they gained quite a lot of performance when optimizing bounding geometry for their particles, they also have great presentation about vertex packing.

1 Like

Thanks for this, Raven. I feel most of it is out of scope for me, but I always enjoy readings like this for the clever tricks you can pick-up and implement in other circumstances. :wink:

Are you sure the Draw time is your bottle neck?

Have you run the profiler against it to see where all the time is actually being spent?

Hi there Arcade!

I have no bottlenecks at this time. I am really happy with the performance so far.

Asked because I am reaching a stage where I expect a lot of complex drawing to be done and I wanted to take a bit of advantage on the experience of the community here, just to have a helicopter view of what I can look at. I don’t really expect a performance degradation, but just in case I run over one, to have an idea what are the points I can try. The transparency rendering was a bit unclear for me, thus this topic. :smiley:


Keep in mind that for static scene elements, you only really have to compose this once. You can cache the result in a RenderTarget2D and render the final output via a much smaller subset of draw calls.

Thanks for this, I’ll give it a read :slight_smile:
(I was mostly wondering if anybody could find that old link though because I just wanted to watch it again. It’s been quite some time and it was interesting! Might just be one of those things that’s lost to time though, lol.)

It probably doesn’t fit the time frame, but I believe for example Slay the Spire does it, small chance they were the ones that make video about it tho.

Random video on given topic: How to create custom sprite meshes to reduce overdraw, tri-count and improve performance in Unity 2D - YouTube

Nope, definitely not it. It wasn’t something in unity, maybe? All I know is that the game was a platformer and had some tie in with music, or a beat, that you somehow played to? Maybe?

Either way, yea this is for sure the same concept.