Overview
When creating visually rich scenes in Unity, you naturally want to place many objects and materials. However, you've likely noticed frame rates dropping as object count increases. Behind this rendering performance degradation lies the concept of Draw Calls.
A draw call is a command from the CPU to the GPU (graphics card) saying "draw this object, with this material, at this position." Each time an object is drawn, a draw call is typically issued. The act of issuing these commands itself creates significant CPU overhead. When draw call counts become too high, the CPU becomes the bottleneck—even while the GPU sits idle—capping your performance.
This article explores what draw calls are and how Unity's powerful automatic optimization technique, Batching, works to reduce them.
What Are Draw Calls?
The process of the CPU commanding the GPU to draw isn't as simple as saying "draw this." It actually requires a series of preparations and instructions:
- Set Render State: Configure detailed GPU settings—which shader to use, which textures to bind, lighting and blend modes, etc.
- Transfer Mesh Data: Send the vertex data (mesh) of the object to be drawn to the GPU.
- Issue Draw Command: Once everything is ready, finally issue the "draw now!" command (the draw call).
The problem is that objects with different materials require different render states, so they must be drawn with separate draw calls. For example, even if a red car and blue car share the same mesh, their different materials require two draw calls.
If your scene has 1000 objects each with unique materials, that's 1000 draw calls per frame—a massive CPU burden.
Batching: Combining Draw Calls
Batching solves this problem. It's a collective term for techniques that "combine multiple objects into a single draw call." This dramatically reduces the number of CPU-to-GPU commands.
Unity provides two main automatic batching techniques:
- Static Batching
- Dynamic Batching
Static Batching
Static batching is a highly effective technique for non-moving objects.
- How it works: At build time, Unity finds objects marked as "Static" that share the same material and combines their meshes into one large mesh. At runtime, this combined mesh is drawn in a single draw call.
- Usage: Select objects in the Inspector and check the
Staticcheckbox in the upper right. (Batching Staticis sufficient) - Pros: Extremely effective at reducing draw calls.
- Cons: Only works for stationary objects. Memory usage increases to store the combined mesh.
- Use cases: Background elements, buildings, terrain, static props—all static environmental objects.
Dynamic Batching
Dynamic batching applies to moving objects, but has strict limitations.
- How it works: Each frame, Unity finds objects sharing the same material, combines their vertex data into a single buffer, sends it to the GPU, and draws everything in one call.
- Usage: If
Dynamic Batchingis checked inProject Settings > Player > Other Settings, qualifying objects are batched automatically. - Limitations:
- Object meshes must have very few vertices (typically under a few hundred total).
- Objects with different scales may not batch.
- Doesn't work with multi-pass materials or complex shaders.
- Pros: Reduces draw calls for moving objects.
- Cons: Strict limitations make the effect limited. CPU overhead each frame for finding batch candidates and combining vertex data.
- Use cases: Particles, bullets, simple-shaped enemies—moving objects with low vertex counts.
Manual Techniques for Reducing Draw Calls
When automatic batching isn't enough, designers and programmers need conscious optimization strategies.
Texture Atlases
Combine multiple small textures into a single large texture. This enables multiple objects to share the same material, greatly increasing batching opportunities.
For example, if background props (rocks, trees, grass) each have separate textures and materials, draw calls multiply. Combining these textures into an "atlas" and adjusting UVs lets them share one material, enabling static batching to draw them all in one call.
GPU Instancing
A technique for rapidly drawing large numbers of objects sharing the same mesh and material in a single draw call. Extremely effective for grass, trees, crowds —large quantities of identical-looking objects.
- Usage: Check
Enable GPU Instancingin the material's Inspector. - Features: Each instance can have individual properties like position, rotation, and color. Unlike static batching, objects can move.
Checking Draw Call Count
Current draw call count (shown as Batches in Unity) is visible in the Game view's Stats window. This Batches number indicates CPU rendering load. Always monitor this value when optimizing.
Summary
Draw call optimization is one of the most important factors for improving Unity's rendering performance.
- Draw calls are CPU-to-GPU rendering commands. Too many create a CPU bottleneck.
- Batching combines draw calls.
- Static Batching: Extremely effective for non-moving objects. Just enable the
Staticflag. - Dynamic Batching: Limited effectiveness for small moving objects.
- Texture Atlases: The classic technique for consolidating materials and promoting batching.
- GPU Instancing: The ultimate weapon for drawing many identical objects.
Understanding these techniques and building scenes while monitoring Batches in the Stats window enables development of games with both rich visuals and high performance.