Going mobile is not easy, so you must consider it from the beginning.
So I decided to develop a new project for the mobile devices and having a simple structure working I started looking at de frame rate and, surprise surprise, it look bad. I mean it was 6 to 8 frames per second and the scene was almost empty.
Then I look at the bag of optimizations and started the kung fu:
- first simplify the models, less vertices, less faces, less edges all led to faster rendering;
- change the Unity shaders to mobile;
- I'm using a terrain so looking at the options I started messing with this:
- pixel error;
- base map distance;
- detail distance;
- Theres one directional light in the scene so here's what I changed:
- baking to baked;
- shadows to hard shadows;
In the scripts I looked at:
- string concatenation - make it with stringbuilder;
- function calls, some times can be avoided;
- some functions can be optimizaded like the Mathf.Abs that I changed for x = (x > 0 ? x : -x).
After all this tricks I get 20 frames per second, not bad! And the frame rate is stabel, not droping has I add more elements to the scene.
There are some more changes that I'm going to test with the physics engine but for now I'm happy.
So I decided to develop a new project for the mobile devices and having a simple structure working I started looking at de frame rate and, surprise surprise, it look bad. I mean it was 6 to 8 frames per second and the scene was almost empty.
Then I look at the bag of optimizations and started the kung fu:
- first simplify the models, less vertices, less faces, less edges all led to faster rendering;
- change the Unity shaders to mobile;
- I'm using a terrain so looking at the options I started messing with this:
- pixel error;
- base map distance;
- detail distance;
- Theres one directional light in the scene so here's what I changed:
- baking to baked;
- shadows to hard shadows;
In the scripts I looked at:
- string concatenation - make it with stringbuilder;
- function calls, some times can be avoided;
- some functions can be optimizaded like the Mathf.Abs that I changed for x = (x > 0 ? x : -x).
After all this tricks I get 20 frames per second, not bad! And the frame rate is stabel, not droping has I add more elements to the scene.
There are some more changes that I'm going to test with the physics engine but for now I'm happy.
Comentários
Enviar um comentário