I`m starting make my first game for iPad (it is similar to Tower Defence) and in my game i wanna operate about 40-90 units with AI, Animations, Meshes, etc…
I`m downloaded from store some lowpoly models (~ 2000 vertxes, 2000 triangles), add them to scene with terrain and light, add unit spawner, run it in my iPad 2, test performance and get this results:
Unit Count
FPS
35
23
45
21
90
5-10
Ive reduced texturesize from 1024x1024 to 256x256, switched animatons off, set quality settings to Simlpe - all this thigns has no effect: ive get only + 1.5 FPS after this changes. And i keep in mind that i should add AI, improve video settings, and i have troubles in my game.
So,
What do I do wrong ? Why FPS falls down so fast with so little number of unit in viewport?
May be my models should be smaller and more LOWpoly? What number of polygons in viewport is appropriate for Unity on iPad?
My assets use SkinnedMeshes, may be it is the trouble point?
Does anybody knows unity iPad game with big amount of units in viewport?
What are general ways to optimize Unity game performance to iPad?
PS. Targetdevices for me are iPad 2, 3, 4 and minis.
how many draw calls per unit
4 draw call per unit (i`seen in in “Stats” bar)
how about static/dynamic batching?
If i set prefab to static Statistics tells me that it is save 69/297 DC for 90 units. It helps me save about 2-3 FPS when 90 units in scene, but only when animatons is off.
You may try to stay in a 30 ~ 60 draw call for all your scene element to be somewhat comfortable.
4 call per unit will put you way over.
I see you have terrain and light ? well start by get rid of those and check back the perf you get.
take care the shader/material you are using.
also 2000 poly for unit maybbe too much as well , really depending on how close you see them…you could think about LOD for this
as for texture size well a basic rule is to consider the maximum size you need from the maximum size in pixel your model will show up…in other terms if a model do not take more than 200x150 pixel on screen , you dont eventually need 1k texture for it.
try by ditching some stuff and see what you get back
Also if youbget pro unityn, just check profiler infos, otherwise you can check the internal profiler from xcode gdb that will give you some clue already on time spent on things like rendering, update etc…
This will then let you get 30-60 units onscreen, resulting in 30-60 drawcalls.
However if you want to get fancy, there is more you could do. I’ve thought about this quite a bit because I was planning to make a riot game with lots of people running about.
The different techniques you could use are as follows:
This would be the easiest, and potentially best way, and could get you 100+ of guys on screen easily, maybe 200+ (never tested so I’m not sure the exact numbert). Rely on dynamic batching. So each unit on screen has to be less than 300 vertices, theres also little more that has to be taken into account, read about how to get objects dynamically batching. Albeit, due to each unit needing to be less than 300 vertices, your units won’t be very detailed. But if your making a game thats going to have 100+ units on screen, each unit is probably going to only be taking up like 10x10 to 20x20 pixels of screen space. With something taking up so few pixels you could make something that looks quite good with very few polys. You can’t have skinned animation meshes with this because those don’t batch. But you could do something where each unit has a walk cycle created by having 4 to 6 different meshes, then just iterate through the visibility of these meshes. The walk cycle would obviously be a little jerky, but again, with each unity being so small, you could still make it look good, and it could be played into being a stylistic thing in the game as well.
This was would be a little more involved, but probably not too difficult. Make use of meshbaker http://forum.unity3d.com/threads/159258-Mesh-Baker-by-Digital-Opus-RELEASED
You can combine multiple skinned meshes into one large skinned mesh while retaining the original animations. So you would not be relying on dynamic batching, so your units could have more than 300 vertices. You would use mesh baker to combine your units into clumps of like 5 or 10. Then you could draw much much more units with fewer drawcalls. However with this, if your going to be using skeletal animation, the amount of bones your going to end up with on screen may be huge. So you would really want to minimize the amount of bones in each character radically. Like try to get away with just 5 if you could, 1 for each foot, 1 for each hand and one root joint, no knee or elbow joints. This wouldn’t allow for detailed animations but with 100+ units on screen and each one being so small, you could probably produce a pretty good effect with this. I don’t think you could get as many units on screen with this method, although I’m not sure I haven’t tested it, but I’m pretty sure it would let you get at least 100 depending, and they would look better than method 1.
You could make use of the mesh particle instancing. This would probably let you get the most units, with the most detail on screen. BUT they could not have any animations on them. So I don’t know how well that would work out. Maybe for a special type of unit not needing animations you could use this for.
Hi,
Very nice post techmage, thanks for the insight.
As an alternative for displaying many units on IOS you could also bake your animated 3d character sequences to sprite sheets. The rendering cost of quads displaying them permits many simultaneous units on screen. This is a technique used in clash of clans and many other games.
Thank you, guys, a LOT for your so detalied answers and advices. Im going to take your advices, optimize my game and then Ill post the results. It would be soon.