Lesson 93 +10 XP

Draw Call Batching

Draw Call Batching

A draw call is a command sent from the CPU to the GPU to render an object. Too many draw calls bottleneck the CPU. Batching combines multiple objects into a single draw call.

Types of Batching

1. Static Batching

Combines static meshes that share the same material at build time. Best for large numbers of non-moving objects like terrain details, rocks, and buildings.

How to enable: Mark each GameObject as Batching Static in the Inspector's Static dropdown. Unity merges them at build time (or when loading a scene).

  • Pro: Zero runtime CPU cost.
  • Con: Cannot move the objects after batching. Increases memory usage because each mesh is duplicated in the combined mesh.

2. Dynamic Batching

Unity automatically batches small, moving meshes that share the same material each frame. It is enabled by default in Player Settings.

  • Mesh must have fewer than 300 vertices (and meet other criteria like no different scales).
  • Pro: Works with moving objects.
  • Con: CPU transforms all vertices per frame, so only works for very small meshes.

3. GPU Instancing

Renders many copies of the same mesh and material in a single draw call by passing per-instance data (position, color, etc.) to the shader. Ideal for crowds, trees, and particles.

How to enable: Check Enable GPU Instancing on the material.

// Set per-instance properties via MaterialPropertyBlock
MaterialPropertyBlock props = new MaterialPropertyBlock();
Renderer rend = GetComponent<Renderer>();
props.SetColor("_Color", Color.red);
rend.SetPropertyBlock(props);

4. SRP Batcher

Available in URP and HDRP. Reduces the CPU overhead of preparing draw calls for materials that use SRP-compatible shaders. Materials do NOT need to be identical, only their shaders do.

Pro: Works with many unique materials. Very effective in URP/HDRP projects.

Checking Batching in the Stats Panel

In the Game view, click Stats to see:

  • Batches: Total draw calls. Lower is better.
  • Saved by batching: Number of draw calls eliminated by batching.

TL;DR

  • Static Batching: Non-moving objects, same material. Zero runtime cost. Enable "Batching Static".
  • Dynamic Batching: Moving small meshes (<300 vertices), same material. Automatic.
  • GPU Instancing: Many copies of same mesh/material. Enable on the material.
  • SRP Batcher: URP/HDRP. Reduces CPU overhead per draw call regardless of material uniqueness.