- Home /
optimizing ipad performance with draw calls
Hi everyone,
I've been trying to analyze what causes the fps going down so low in my game, and after I tested in couple scenario, it seems reducing draw calls is my prime target. So here are the 3 main problems I'm facing
The problem is I have a prefab of group of archers (4x4 = 16 archer models) and each model contains a bow, a quiver, an arrow, and the archer model itself. Totalling 16 archers * 4 geometries = 64 draw calls for 1 group. And the worst case scenario is there will be 8 groups of archers in screen, totalling 512 draw calls. Even if Unity batches them, I still ends with around 220~230+ draw calls and 360+ batched draw calls.
The next logical step I have is to combine those 4 geometries into 1. However after trying to use CombineMesh() from the Unity Script Reference page, the bow, arrow, and quiver are no longer in the appropriate position and more importantly, they don't animate anymore.
The rigger said those 3 components are parented to the archer left hand, right hand, and back respectively.
Is it a good idea to tell the modeller/rigger to combine those 4 geometries into 1? Is it possible? Or do I have any other options for combining those actually-passive meshes into 1 with the body but still preserving the animation ?
Furthermore, I'd like to ask what's the maximum draw calls/tris count should be allowed in deployment in iPad? Currently I have about close to 400 draw calls and 350+ batched call with 70k tris (degenerate triangles included)-9.1k batched, and 37k verts-4.3k batched. And that makes the fps drops to 13 fps.
There's one scenario with 236 draw calls, 40.5k tris and 19k verts with 0 batch on them allows the game run at 25~26 fps.
So I'm guessing <200 draw call with <60k tris should be my aim?
The degenerate triangles due to stripifying process in the models already doubles the tris count when the scene is deployed in iPad. Can I reduce the number of degenerate triangles further than factor 2.0 ?
P.S : Why is that when I use OnGUI() function, the batching (especially tris and verts) go down in the gutter? This only occurs when deploying to iPad, not in Mac/Window environment
Thanks in Advance,
Answer by flamy · Dec 20, 2011 at 06:11 AM
upto 120 or 130 draw calls it wont give problems! and draw call isnt the only thing that affects the performance! chck for number of tris and also VRAM it is using in the ipad resolution! And also u can reduce the draw calls from OnGUI() function by enclosing all the contents inside a if loop like this one
if(Event.current==EventType.Repaint)
{
//ur GUI content
}
The above code would reduce teh draw call by half from the GUI part of the game!
also try to make models such a way that the archer model, bow and quiver (or even arrows!!) share a single material!! this would reduce the draw call from 64(as u said) to 32!!
Then check for the shaders you are using and the number of passes in it !! this could also cause the increase the draw calls!
And if u r using instantiate and Destroy for shooting of arrows change the logic and jus translate them with the one attached to the bow. Instantiate and destroy are costly! like wise i can say a lot of suggestions but better look into Optmizing for IOS page of unity!
hope it helps :)
Thanks for the reply, flamy.
Is that snippet supposedly to be put inside the OnGUI() loop? It's good to know!
The materials for those 4 objects, in fact, are the same. Though I don't understand why the draw call would be reduced to half (ins$$anonymous$$d.. to 1/4 because there are 4 textured geometries) if I didn't use the same material.
For the shader I use the default $$anonymous$$obile/vertexLit shader. Isn't this the cheapest shader we can afford?
For the arrow firing, I think I will simply generate a particle effect to accomodate such effects.
ya put that snippet inside all your OnGUI fuctions and enclose all the code inside it into this loop!
actully i thought you would have separate material for arrow (in case of instantiating!) thats y said 1/2 !
ya vertexLit is the cheapest, no problem with that!
translating an arrow mesh would be much cheaper and effective than particles! and i belive would give a better look too (jus a suggestion, you can go with particles, if it is proprely optimized!)
PS : you can use light mapped textures for static meshes (if any) and reduce the lighting calculation (if any)
Hmmm... even then, I still observe that the draw call is more affected by the number of geometries drawn in the camera view frustum, while sharing as many materials as possible increases the number of batched draw call.
So back to the idea of importing the 16 archers as 1 model and animating them altogether. Would that be a good thing to do? Will the tris count explodes exponentially if I were to do that?
actually im dont have much knowledge with 3d models and stuffs =/ What i assume is it might be better if u do so!! but if the archer has to move or soemthing, this method wouldn't be feasible !
and another better suggestion would be reducing the VRA$$anonymous$$ usage by reducing the weight of model geometry(No. of poly), reducing the aniso level of textures applied to the distant objects!
Your answer
Follow this Question
Related Questions
Drawcalls or Batched, which is more important to performace? 1 Answer
Dynamic Batching, Combine Meshes? 1 Answer
Excessive VBOs and no batching while instantiating prefabs 0 Answers
Best way to create/design modular Player 2 Answers
What is a reasonable number of draw calls relative to one hardware configuration ? 6 Answers