Following on from "What is a reasonable number of draw calls relative to one hardware configuration ? @ http://answers.unity3d.com/questions/2117
what's the best way to reduce draw calls?
EDIT : Link updated to Qato link
Draw calls, broadly speaking, are similar to when a painter has to un-load their brush with one colour of paint, and load it up with another, before continuing to draw.
In GPU terms though, the different "paint colours" equates to different materials in your scene, and different models which can move independently.
Therefore, you can reduce these number of draw calls by designing the objects in your scene so that as much as possible can be drawn with each single "call".
Combining Meshes of the same material & texture.
You can automatically combine meshes in Unity using the CombineChildren script provided in the Standard Assets package.
Combining Meshes with different materials & textures.
For example, if you had a building which uses different textures for the roof, doors, walls, beams, cornerstones, windows, etc, you might combine these into a single texture atlas. In doing this, you sacrifice the ability to use a different material for each item, but you gain the benefit of being able to collapse the various parts of the building into a single mesh with a single material, therefore enabling you to draw the entire building in 1 call, instead of many:
Typically though, the original "window" material might be transparent and reflective, and therefore wouldn't necessarily be suitable to be merged down into a single material with the other textures, so you might end up with two texture atlases for the final building. One for the opaque, non-reflective parts, and one for the transparent reflective parts.
If you then also have lots of buildings which use these same textures, you could combine these building meshes together too - so for example, you might end up with 10 buildings drawn with just two draw calls: one mesh (and one call) for the combined opaque parts of all 10 buildings, and another mesh & call for the combined transparent reflective parts of all 10 buildings.
This page on GamaSutra has an example of a tightly packed texture atlas which encompasses many objects into one texture: GamaSutra - Practical Texture Atlases
And here's a 3ds Max script which automatically generates texture atlases for you: Texture Atlas Generator. This is worth looking at even if you don't have 3ds Max, because the page has some good animated examples of how a texture atlas is formed.
Texture atlases are also commonly used in games which use 2D sprites for similar reasons, to avoid having to use different materials for each object, and to combine many frames of animation on to a single texture. In these cases they're sometimes referred to as Sprite Sheets.
Another point worth noting is that Unity iPhone supports an automatic batching feature, which automatically combines meshes which share the same material. This means that you can even reduce draw calls further by sharing materials between objects that are moving relative to each other in the scene! (Hopefully this feature will make it into the regular version of unity at some point, but that is just speculation for now!).
Combine objects using the same material into one object (or at least fewer objects), either manually or with the CombineChildren script. If this isn't feasible because of having too many different materials, you can make fewer materials by combining different textures into texture atlases and then UV mapping objects which used those textures to take advantage of this. Then, with fewer materials, you'll have more objects that can be combined.
answered Apr 07 '10 at 10:00 AM
all good!.. and dont forget to disable invisible objects in camera culling mask...
answered Sep 23 '10 at 10:34 PM
For GUI-related stuff, you could use NGUI. For me, in my inventory system I had almost a 300 draw calls drop by using NGUI instead of UnityGUI. It gathers your textures and put them in an atlas, uses other techniques as well to reduce draw calls. Results are impressive.
answered Aug 13 '13 at 01:42 PM