Today, I faced a performance issue within a heritage game. As performance issue I mean that the game frame rate goes periodically dowm around 10-20fps. It is really annoying for the player. In this post I simply and quickly report just the things that I checked, and worked for my use case obtaining an improvement of the overall performance.

Use different layers

In order to optimise the performance of a huge map the first thing to check is the use of multiple Unity layers. One of the common error is to merge all the world or part of it in a couple of Unity layers without a good separation of concerns. Of course, the use of few layers introduces a performance issue and it is a bed programming practice. For instance, if you have a pool within your game or any other surface that reflects the lights, having everything within the same layer force the Unity engine to calculate the reflections and refractions for each geometry within the same layer introducing a performance issue. A rule to follow is to have the water and the reflected objects in at least two separate Unity layers. Everything else must be placed in other different layers, not in the same water or terrain layer. The use of multiple Unity layers is the right way to face the performance issues. In this way, when you select the water you can easily select the refractive water mode and choose the layers that you desire to reflect within the water. In this way, the section Refract Layers there will be "Mixed".

Unity Water

Terrain optimisation

Another aspect that reduces the game performance is a very huge terrain with grass and trees. I noticed a performance degradation when the terrain has a lot of trees and grass. The way to optimise is to act on the terrain parameters. In order to access to the terrain parameters, you must select it, and then click on the settings icon as shown in the picture below.

Unity Terrain Options

Two parameters you could change. The first one is the detail density. I noticed that reducing this parameter the performance will increase but at same time the user will not notice the difference in terms of quality. The density express the quantity of grass for unit of area. So, a lower value means that the game will render less grass for unit of area. In this way, the game performance will be better and the quality will remain almost the same, unless you don't fly within the game having an overview of the whole terrain.

In addition also the texture size impacts on the performances so you need to find the best trade off between quality and performance.

Conclusions

Obviously, the previous considerations are based on my experience and I'm sure that they strongly depend on the game type. Of course, there are other kinds of check and optimisations that you can try on your game. Let me know your experience and your tests.

Game optimisation in Unity 5.00/5 (100.00%) 1 vote

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>