- Home /
how draw call,tris and verts work on unity?
In unity 4.3 i have 30 objects as single sprite that get it from 30files(png). when the game start it make 30 draw calls.But when i use one file(png) that have 30 pictures and then i use sprite mode Multiple it make 1 draw call but it have more tris and verts.I don't know which way that i should choose? have anyone can explain? thanks!
Answer by flamy · Feb 03, 2014 at 06:22 AM
Draw calls are directly proportional to the number of materials in the scene (To keep it simple). If you see 30 draw calls, it means your camera has to draw 30 times a frame. It is always good to have this number as a lower value because in MOST cases having less draw call means better performance because less work for the renderer. There are few materials which requires the camera to draw multiple time, a good example is transparency materials which has transparent shaders which would draw multiple times for a single instance of object.
Batching is a technique to reduce draw calls in game. What it does is it groups objects with same material and draw it in a single draw call, this way the performance on the renderer can be improved. But this cannot be done in all cases, for example if each individual object has animation attached or the scale value is varying or the size of the object is big (number of tris is more), it cannot be batched.
What is happening in your project is dynamic batching, you have only one material for all 30 objects by creating a sprite this way the draw calls are reduced, which is always the better method because having 30 files means you are allocating 30 different textures in memmory, which would be definitely higher compared to one single file. But make sure to keep this sprite size as low as 2048x2048 if you are targeting iphone and android phones because in most of the android phones and lower end iphones the max texture size supported is 2048x2048 (some even have 1024x1024 limit but i wonder if anyone are still targeting those phones.)
Number of time the camera has to render depends on the number of draw calls, similarly the amount of time taken for the renderer to complete drawing one material depends on the number of tris on the object. You can have 1000 objects with 2 tris each and 50 objects with 1000 tris each. though the number of draw calls in case one is 1000, it would be relatively faster than case 2 which has jus 50 draw calls, because in case 2 it takes more time for a single object to be drawn.
So I would vote for your second method. But jus curious how much is the verts before and after using sprites?
thanks for your answer.but i'm not clear about it: -$$anonymous$$y first method: I use 30 material(having 30 draw calls) -$$anonymous$$y second:I use 1 material(having 1 draw call and more tris and vert) You have vote my second method is better.
And your Example: You can have 1000 objects with 2 tris each and 50 objects with 1000 tris each. though the number of draw calls in case one is 1000, it would be relatively faster than case 2 which has jus 50 draw calls, because in case 2 it takes more time for a single object to be drawn.
So you meaning case one(1000 draw calls) that have draw calls bigger than case two(50 draw calls) it relatively faster than right? it's so opposite my method.
Hope you detail to me clear please. thanks.
yes what i have said is true in above case because the amount of tris is much greater or in 1000s hence the performance would drop evn whn draw call is more. what i tried telling u is that draw call isnt the only factor to affect the performance. Even number of tris can affect.
in your case you are using 2D sprites so the vertex count cannot go way higher than the original one before batching. It is just the comparison of 1000 boxes vs 1000 cars, obv both wont have same performance. But in this case even before batching it was jus boxes but the count varies 30 box vs 1 box now.
Wat I said is a rare case where you have to change from 1000 boxes to 100 cars which will still have more geometry to draw than 1000 boxes....
A geometry is always formed from triangles, Imagine in a box of 6 sides it would have only 12 triangles. but for a car imagine how many triangle would be there.
tris = Triangle vertex = points (imagine in case of a cube it is the corners)
Your answer
Follow this Question
Related Questions
Jelly Object for 2D Game 2 Answers
Determine Texture Size 0 Answers
Make a sprite black and white. 2 Answers
Grow Sprite image size from Edges instead of Center. 0 Answers
Object dragging at manual point 2 Answers