Overdraws: Why should we tame this monster!
Overdraws are the most underestimated performance bottleneck in game development especially when it comes to mobile game development and the recent XR app space where game engines are used.
Before we jump to why overdraws are the problem and how can we control them let's try to understand overdraw with this simple real-life example.
Suppose you see a kid playing with a bubble.
Now suppose you are wearing specs, and it has broken and it has some layer of dust on it.
So in order to view the kid first, you have to see through your spec’s lens then you have to see through the broken view and final those nasty dust. As you can see there are multiple layers of obstacles that are being drawn before the final view, these are called Overdraws.
In Unity, Overdraws happens when the same pixel is drawn multiple times in a single frame.
Now you must be thinking why it is so dangerous?
As you know rendering happens inside the frame buffer, and drawing into the frame buffer is costly in terms of memory, so the more pixels we draw the more memory it consumes which eventually affects your performance.
You must be thinking about how can we reduce overdraws, here are few tips:
- Using transparency wisely as alpha blending is costly in terms of graphics .
- Packing Sprite tightly can help you to reduce the overdraw.
- Using Additive Shader in replacement of alpha-blended shader if possible.
- Avoid Post Processing, post-processing always adds a new layer of overdraw so if we can avoid it that will save us from 1x overdraw.
- Particle Systems are masters of overdraws, So try to reduce the number of particle systems in your scene to avoid overdraws especially on mobile devices.
- Last, not least and I hate to say this, Batching Causes Overdraws!!!! Yes, you read it right any type of batching causes overdraws as we are not able to sort the geometry once we batch them together in a draw call which leads to overdraws so it's better not batch elements that have severe overdraws.