Keep it simple, stupid
After several weeks of work with the character animation we found that our framerate fall under 10fps and this is not a good option. So...we look on the profiler trying to find what stuff is causing our new headache.
And we found tree causes for this issue:
- Animation Blending
- Terrain resolution
- LODs (work in progress)
This week we found the way to solve the first on the list. "Animation Blending". Each time we check or assign a variable on the animator controller the mesh animation is calculated on the CPU. This means that if we have 10 characters and we set or check the values each frame, we are repeating the same work too many times. This part was easy to solve because we can store the animator variables on auxiliar variables and with this avoid to check the status and we set the variables only when a change happens.
But even doing this changes the animation blending process was a very heavy process. So... what is happening? Initialy we think that make little animations and blend it on Mecanim was a good option because this reduce our "animation time" with Maya, but this has a lateral effect. Each blending layer implies a lot of operations over each vertex on our model geometry. This operations are made by CPU , not GPU, so they are not so faster as we expect.
So "Keep it simple". we reduce the number of layers on mecanim to two and we blend the animations on Maya so they were precalculated on the game. Now on the first layer have the basic movement animations and the second one has the attacks. Once this was done the profiler show that the CPU usage was decrease dramaticaly.
The second issue with the terrain is a little bit more complex. We set the resolution o our terrain to a value that maybe is to high for our map style. Our map is a big plane with little hills on the borders. And we don't undertand why Unity uses more than a million triangles for render this terrain. Obviously this is a bottleneck and we want to fix it as soon as possible because we want to use this triangles for drawing another stuff.
And LODs is a work in progress. Is quite probalble that we will made 2 lods for each model. In this way, our models are the level 0 and we need to model now the level 1 with less triangles. And then, set up the lod group component on Unity.
No comments:
Post a Comment