Animations Are Evil, Performance Rules

While working at our upcoming game Momo, I am keeping a close eye on performance. It needs to run smoothly (60fps) on an iPhone 3GS, and that is a constant challenge.

While its great to develop for mobile platforms, it can get tricky when you don’t obey the Golden Performance Rules of Lukas. 😉

There are a some simple rules like:

  • Forget about pixellights, too expensive (although the new hardware is looking promising!)
  • Keep your drawcall count low as graphic state changes are cpu expensive
  • Mark objects that don’t move as static
  • If they move, try to keep ’em below 300 vertices, it will then be dynamicly batched
  • Don’t instantiate or destroy objects in runtime as memory is slow and it will create hiccups
  • Don’t alpha reject pixels on iOS devices because its slow on tile based rendering, use alpha blend instead
  • Don’t talk about polygon count but vertex count
  • Don’t rely on the 3D modelings package for your total vertex count, use the 3D engine instead as a number of things can influence this number
  • Don’t non-uniform scale your objects in an animation as they won’t be batched

On this last one I have a good example, with some pictures. (yay pictures!)

So here we have a nice cracked rock

rock_before

In the game it will crack and fall apart

rock_after

But wait, 2 drawcalls?

stats_before

The complete asset is only 176 vertices and it should batch! Well it is batched, partially. Lets investigate it. The rock consists of 6 pieces. All using the same material? Check. All under 300 vertices? Check. All scales are uniform? Check. Or is it? Well on start it is but in the animation one of the rocks is slightly scaled in the x and y axis.

scale

Okay, so walk to the artist, I tell him, he frowns, I explain, he frowns, he fixes, all happy.

stats_after

At the bottomline: performance isn’t only a programmers thing anymore. For mobile, a lot depends on how game assets are created, you can’t get away with sloppyness anymore.

Oh and by the way, if you are an artist and you want to go up a few levels, please please please read the book Creating 3D Game Art for the iPhone with Unity. It will make your and my life a lot easier. It has been written by and for the game artist but even I enjoyed reading it!

3 Comments
  • mipago
    Posted at 14:13h, 13 December

    thanks for your tutorials, I want to buy the book.
    but I need to know, what is the real deal.

    please tell me the price and content of the book

  • Alok Krishali
    Posted at 19:18h, 23 January

    I am new in unity Game development…Yesterday a work has given to me..I have to optimize a sniper shoot game..that is for VR. So during game start some jurk is coming in game..When i saw unity profiler. It showed some hump in render..On detail i saw Occlusion Culling.. How to improve.. and optimize..Also tell me about how to apply static batching in unity game.

Post A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.