Draw calls and improving performance.

Hi, I’ve been learning Unity for several months now and have learned a lot about different performance techniques. One think that I keep hearing about on all the tutorials I’ve watched, but is never really full explained is regarding – “draw calls.”

I understand that keeping draw calls down is definitely advisable. However, what is a good rule of thumb for doing so on different platforms? - In other words, the need to keep draw calls down on a game for my PC is probably going to be very different than a game that is designed for the iPhone. So, where does one feel comfortable with the thought of “keeping draw calls down” on different platforms?

Is there some sort of rule or best practice that one should aspire to achieve when creating a game in terms of draw calls?

Thanks,
Calixto

Well as you mentioned its subjective to each platform, a desktop can handle many more than a mobile device.

Its good to get into the practice of understanding the techniques for reducing draw calls where you can on any platform eg using texture atlases and combinations of layer masks for dynamic and baked lighting for static and moving objects etc.

Outside of these kind of obvious optimizations its again platform specific. Some of the hoops you jump through to reduce draw calls on mobile are not applicable to desktop when you know you have the processing power to have very cool shaders like normal maps on everything and spec shaders , more lights and effects etc…

Hi Shaderbytes, thank you for your reply. I think you know what I’m struggling with…some of the videos I’ve watched state that 51 draw calls is good, however, my question when I heard that is…good for what type of platform? I’m sure 51 draw calls was OK for a PC or a Mac, but what about a iPhone 4? I was hoping there was some way (other than testing) to try and determine how much is “too much.”

Thanks for your help,
Calixto

Complete answer:

Just by looking at Unity demo scenes you can understand that on mobile devices between 50 and 200 is ok(Just look at angrybots) and for pc it can be so much higher.
In Bootcamp demo scene at lowest quality draw call is about 170 and at highest quality it is about 2000 but for high end systems like I7 2nd and 3rd generation draw call can be even more than 10000 in my tests.
In our latest project which is an open world game,before optimizing we have about 10K draw call,5.2M tris,6.1M Vertics,Used textures 507-98MB,Shadow caster 1199,resolution 1920*1080,and I’m having 50-65 fps on a GTX 580 vga and I7-2600K cpu.
Note that shadow caster will calculating as draw call,for example draw call is 2000 and shadow caster is 500,if you turn off the shadows then the draw call will reduce to 1500.

There are many ways to reduce draw calls:
Dynamic batching and static batching are two of them,go to edit>project settings>player and switch them on.
Dynamic batching for scenes contains lots of dynamic models using same materials like cars,characters,etc.
And use static batching for static objects.
Another way is to use “combine children” script which comes with unity.
This scripts can be apply to a parent model which has many children using same materials.
All those 3 ways will affect on the CPU as they are running in game and will apply to each frame.
The best way of reducing is combining models in your 3D program like Maya,but remember that even if you see only a little part of your model,the whole object will render so do not combine whole scene,just combine those models which are near to each other(only combine those sharing the same material).

If you add the option for reducing the shadow quality or even turning it off you can reduce the draw call so much.
You can even uncheck “cast shadows” for unimportant objects.

If you can’t see the image use this link:
http://s2.picofile.com/file/7654702254/Cast_shadow.jpg

Hi Hotsun, thank you!!! This is EXCELLENT…simply EXCELLENT!!! This is what I was hoping for, a frame of reference. I know that all games will be different, but like in everything, there needs to be a frame of reference and you certainly helped me find it here. Thank you for the reference to the other games and what to look for.

Very instructive post…thanks again!!!
Calixto

I think many game designers are having problem with reducing draw calls,Right now I am working on 3 different very hard projects,so after that I can make a video tutorial about draw calls.
And your welcome :wink:

Wow…Hotsun, that would be fantastic. That is going way beyond the call of duty!!! Thank you. I look forward to your video. – BTW, where would you post it so I can look out for it periodically?

Thanks again and good luck on your 3 projects!!!
Calixto

Game designing is really complicate and there are even more ways for reducing draw calls and there are many guys don’t know how to reduce them,specially in Unity’s forum,after finding a free time I will make that video and post it on youtube and will post a new thread in the teaching part,maybe called optimization and talk about not only draw calls but also everything to optimize a game.

As I said before one of our projects is an open world game like GTA and optimizing is really important in that kind of games,another one is an FPS open world on mobile devices which needs even more optimizing so I hope my experiences can be helpful for people around here.

Thanks.

Posting a link in this thread would be great for those that come much later and have the same question. – Thanks again!!!

Calixto