About a month ago I have wrote an article about the optimizations I have done on Wisps in order to get it to run decently on lower end machines.
This time I want to focus on the optimizations I have to do on top of the previous ones in order to get the game running on Android. Unfortunately I wasn’t able to get the game running decently on devices older than Snapdragon S2, but still it was a nice experience to have.
(By the way, you can get the Android version for FREE).
My main objective during this optimization process was getting the number of triangles and draw calls to a minimum, while still keep the polished aspect of the game.
In order to reduce the triangles count I had to simplify the trees, because any triangle saved on one tree could lead to a few hundred saved each frame. The step I took was to remove the trunks of the trees, and that saved up about 6 triangles per tree, reducing the triangles number quite a lot.
What I should have done to optimize it even more would have to render each tree from above and make it exactly 2 triangles, but that would have been a bit too much work involved giving there are a lot of tree types.
I have also reduced shader complexity by dumping the custom “glowing” shader and replace it with a standard mobile alpha test shader that came with Unity.
I have decreased the terrain quality even further, only a few triangles are now used to render it. I now think a better solution would have been to ditch the terrain entirely and use a single big quad to render it.
Textures were downsized to the minimum size possible without damaging the visuals too much.
This was a requirement because I had some game crashes when too big textures being used. Unfortunately this had a negative impact on the tutorial textures, making the text harder to read.
Hiding tree trunks and reducing terrain quality made it a requirement to ditch the perspective camera in favor of an orthographic top-down camera. This way I could hide the imperfections resulted from optimizing the trees and the terrain.
In the PC/Mac version Wisps are spheres, but here I had to reduce the triangles count, and the orthographic camera helped me with that. The result was making all wisps just simple disks that looked the same from the top-down view but were using far fewer triangles than their sphere counterparts.
All shaders were replaced with their mobile counterparts provided by Unity.
All lights, dynamic or static, have been removed and replaced with plain color except for the demigod’s light, which was necessary now to locate the guide when it was getting under the treeline.
Sounds have all been compressed a lot to reduce the .apk size and to make them easier to be loaded and played by the mobile device.
I have turned off some wisps related particle systems and kept only the one used to reveal their location, which had to be rotated a bit to keep the “going up” impression with the new camera. Also the weather effects have been simplified a lot to put less stress on the device.
It took me about 12 hours to make all these changes and it was quite a negative experience to see how much visual detail I had to give up in order to get it running even on powerful devices like the ones powered by the nVidia Tegra 3 chipset. It looks like one of the main factors in rendering speed is the resolution of the device. The game ran decent on older devices with smaller resolution and slowed down a lot to unplayable frame-rates on more powerful devices that also boast bigger resolutions.
My conclusion is that even if Unity is a good tool for developing games for the mobile space, it is certainly not ideal in down-porting such a game from a platform that boats more power.
I have learned from this experience that if the game under development using Unity is planned to get at some point into the mobile space, it should be designed and developed from the beginning to run on such low-power devices, because Unity is not your friend in porting it afterwards, and one may find himself in a situation where too much has to be changed in order to get it to run properly.
Hope this was helpful, please share your experiences with Unity and mobile devices in the comments bellow.