- Home /
Why does the number of draw calls and tris double when I add cars ?
I have a big problem because I built a whole city and subdivided it in a thousand of objects. The average of tris seen is normally 50.0k tris and the average of draw calls is 100, which is perfect (I'm developing on mobile).
However, when I add low poly cars (1000 tris and 10 draw calls each, 15 or 20 rigidbodies active), the average tris become 500.0k, and the average draw calls become 600. How is it possible ? It seems like, because of the cars, the CPU recalculates the city 5 times every frame and it kills my frame rate.
PS: In the Inspector, the ms used for rendering transparent geometry and overdraws gets higher when I add the cars. I tied subdivind more the city, so I solved this problem but I have another one because of 30000 VBO so I had to return to the first problem.
I wouldn't worry too much about the cars at the $$anonymous$$ute. I would worry more about the draw calls, number of tris and the draw calls for each individual car as 10 draw calls for a single car is a bit excessive, otherwise i can almost guarantee that you will have incredible difficulty in achieving any sort of decent frame rate on an average mobile device.
As an example, i'm almost finished my most recent game for mobile, and that has a maximum of 10 draw calls at any one time and a grand total of 5000 tris in the most complex areas. This isn't to say that this is the upper limit. Far from it, but what you seem to be attempting to do will leave you with either a) a very limited number of very recent devices that will run your game smoothly or b) countless one star ratings from slightly older devices that can't run your game at a decent frame rate. All of this is entirely theoretical of course as i don't know all of the details of your project but from what you've said it sounds as though what i've said would apply.
Thank you for your answers ;)
I'm not using realtime shadows because it doubles the draw calls number. The problem is that each car is made of 7 objects: the main mesh, the four wheels, and the two doors, so it makes 7 draw calls or more for the trucks. Do you know a way to have only one draw calls with seven dynamic objects ? Because dynamic batching seems to not be always working…
However, the problem are not the cars because the city works perfectly on my mobile device (iPhone 5), but when I add the cars, it calculates them normally but seems to need more ms to calculate the city (in the Profiler, the part for the transparency rendering gets higher). What can I do to solve that problem ? (Is it overdraw?)
The cars should be 1 object that uses a skinned mesh so the wheels and doors can be animated individually.
Thank you Eric5h5! So if it's the case, and the cars are a skinned mesh, there's no more physics like wheel colliders ? Your idea seems to be interesting, is it possible to make a realistic car only based on direction with animations that fakes the physics ? Thank you :)
Answer by screenname_taken · Jun 11, 2014 at 05:39 PM
Do you have any projector anywhere? That would copy the geometry of what ever projects on.
Thank you it was exactly my problem as each car had a shadow projector, now it runs perfectly on mobile devices !
Give "Fast shadows" from the asset store a try. I had the same issue as you did and because my geometry was relatively flat, i was able to use that for fake shadows. Works really nice and the calls bake together automatically.
Answer by robusto · Jun 08, 2014 at 04:13 PM
To combine the draw calls of the cars they have to share the same material. Which can mean several things. Do the different cars have different material color? having different material color separates them in different draw calls, if you want them to have different colors a trick to use is to use vertex colors. If the cars have transparency also, this also can be done in the vertex color in the alpha channel, which means a different shader(material) for all the transparent geometry.
Sharing the material isn't enough; the objects must have relatively few vertex attributes and dynamic batching must be on. In practice, only very simple objects can be batched. In most cases, every additional object will add one draw call (or more, depending on various factors) regardless of sharing materials.
Your answer
![](https://koobas.hobune.stream/wayback/20220613151059im_/https://answers.unity.com/themes/thub/images/avi.jpg)