Strategys for reducing draw calls

Greetings Folks,

I got a pretty huge problem with my number of draw calls.

I am about to creat a tactical round based roleplaying game and got therefore
a “gameboard”, that is based on gameobjects. At the moment it is a 12x12 field,

The objects come with 4 childs, so I got only the outlines and can coler them seperatly.
Basically, on of the fields countains 5 gameobjects and a gameboard contains 12x12 = 144 of theese objects.

I guess I don’t have to mention that this leads to a huge amount of drawcalls.
So I’m looking for some solutions to reduce them. I got the feeling that I would need to creat a model for each field, what would still lead to 144 (static) gameobjects…

A friend got the idea of creating a “plane” that can mark specific ways on the board.

A marked area should be able to get one of this forms for example.
If I could creat dynamically planes like this with code I could create the complete gameboard with one model, what would heavily reduce the number of drawcalls.

But till now I haven’t found an option of creating planes that aren’t just a rectangle.

Does anyone got a good idea how to reduce the amount of drawcalls while still giving me the ability to let the player see a grid and seperatly mark individual fields?

Thanks for any help!

Reducing draw calls

Method 1 - Dynamic batching:

Unity has a per material batching system. It means, that every objects that share the same material are on the same draw call, and can be sent to the GPU at once.

This means, that for each material, you also get a draw call. To reduce this, you have to reduce the amount of materials.

The most common way of reducing materials is via Texture Atlases. Texture atlas is a big texture, that contains a lot of smaller textures of multiple objects. These objects then share the same material, but each object only uses a small part of it, this can be achieved with modifying it’s UVs.

Texture Atlas

UVs tell the mesh what part of the texture should a polygon get. This is called UV Mapping. If you had a Quad, it’s bottom-left corner would use the 0,0 part of the texture; the bottom-right 1,0; top-left 0,1; and top right 1,1.

Texture atlases and UVs can be generated in many ways, with 3rd party programs or even built-in Unity functions. If you want to know more about the PackTextures Unity function, you should check this forum thread.

Many modelling programs also have tools for creating texture atlases and modifying UVs of meshes.

Method 2 - Programming practices:

The most common programming practice that breaks batching is renderer.material and you should never use it, if you don’t want to break batching. If you call renderer.material on a object that was previously batched, it breaks the batching. So if you want to manipulate the material, you should use renderer.sharedMaterial instead.

Method 3 - Static batching (Pro Only feature):

Static batching allows for better performance when batching, but it can only batch static objects, that are marked static.

Static batching

A static object can’t move, rotate or scale in game, so this should be only used for scenery or props and other static objects on the scene.


eg, notice the important warning here

“If you need to access shared material properties from the scripts, then it is important to note that modifying Renderer.material will create a copy of the material. Instead, you should use Renderer.sharedMaterial to keep material shared.”

Again - what you are doing sounds trivial and should cause you no problem. It’s just a couple hundred flat simple objects, and it sounds like there’s 10 or so varieties of those.

also – as always, many if not most people doing this sort of thing just use 2DToolkit which makes it unbelievably easy and gives you single-draw-call performance

If you use NGUI and You want to use NGUI Atlas on 3D meshes you can get Atlas3D plugin for NGUI. Check the video and tutoraial at: Atlas3D Toolkit tutorial

If you use low poly meshes (not more than 300 vertices) you can get 1 drawcall with many dynamic meshes. Additionally script helps with converting Unity lightmapping and you still get 1 drawcall when using lightmapping on those dynamic meshes. Just like static batching on Unity Pro but you have dynamic meshes free to move and ready for occlusion.