August 29 2022
It depends. But most likely, yes.
This is because 2d games tend to be full of semi-transparent sprites like characters and multiple layers of backgrounds. Which kills performance faster than I kill hunger by going out in Berlin with a €20 bill.
This is why I often get emails asking about this. Last one from Unity game developer Hassan:
I read your article about overdraw and It was very helpful.
I have big problem which is (2d parallax background), the scene consist of 4 layers: Layer 1 take 100% of screen, Layer 2 take 80% of screen and so on.
In overdraw view inside unity editor, the overdraw look very high,
Is there anyway to handle 2D overdraw (there is no transparency to remove)
First: overdraw is a necessary evil when you render semi-transparent materials. You need to merge the color of your new fragment with the color of the existing fragment you rendered previously. So if there is no way to remove transparency, then you are out of luck. I speak of sneaky techniques like using the stencil buffer in the Performance Taskforce module “2022.08”. But there’s just no magic pill (other than working with me ;)).
However, in most parallax setups, you can reduce transparency by cutting “certain” parts of the background to make the sprite a tighter mesh instead of a full rect. Look at the example below (credits to @MobileGameGraph):
It contains many layers of full-rect sprites to allow for the traditional parallax effect (I highlighted in red the full rectangle we render for the front layer). What is cool is that we can potentially cut some areas (in purple) to reduce transparency and therefore overdraw, like in between the trees in layer #2.
Because if you keep stacking full-rect layers like I pile up dirty dishes in the sink in the weekend, it’ll eventually stink. That’s why keeping semi-transparent surfaces small is #1 prio.
There are 5+ more strategies to kill overdraw in this setup coming from the top of my head, but that’s the main one you want to stick to.
This is btw the kind of questions that I like to answer with examples in my Performance Taskforce Q&A’s (next QA is this Wednesday). So if you are curious, you know what to do:
Ruben (The Gamedev Guru)