It’s been a while since mobile devices were only able to support very simple 2D graphics. Even back then people realized that mobile games will grow to become something big, but who knew that it will be so big and so epic at the same time?
Today’s mobile GPUs are getting closer and closer to the previous generation of consoles in means of performance. It’s that amazing! But convenience of having mobile devices so small is bound to impose some compromises. One of them is the number of draw calls that are reasonable to execute per frame.
This simply means that we have to batch things or we will break the game.
For Train Traffic game we’re using Unity as our game engine. Unity has built-in static and dynamic batching mechanism. Both batching algorithms have the limitation of using the same material in order to do the batching, but since some of our objects are moving (yes, we have moving object in our game ;-) there’s one more limitation of 900 vertex attributes per object. Since we’re defining vertex positions, normals and uvs, we are forced to cut down allowed vertices to 300 per object.
Of course the limitation of 300 vertices is something that we couldn’t agree on when creating train models that are bigger than car models, so we decided to sacrifice a little performance over the great look.
Through experience we found out that keeping the number of draw calls around 150 is acceptable, 200 is the limit and 250 results in visible performance loss. Knowing that we started to build our levels.
We knew that there will be a year or more before our game will be released. We also knew that our game will be on the market for some time, so we decided to target the middle-top devices. Still what we yearn most is for our players to have fun with game, so some of graphics features can be turned off in the options menu.
Let's take a look at the very first level of our game.
To render this level without any optimizations Unity requires 942 draw calls. But we were able to reduce it to 177 mostly by batching, terrain optimizations and lightmapping.
And yes, we have dynamic shadows casted by trains! Yet, we're down to 177!
In the part 2 I will talk about tricks that we've used to improve visuals without killing the GPU.
please bring it back