Draw call batching is a draw call optimization method that combines meshes so that Unity can render them in fewer draw calls. Unity provides two built-in draw call batching methods:
Unity’s built-in draw call batching has several advantages over manually merging meshes; most notably, Unity can still cull meshes individually. However, it also has some downsides; static batching incurs memory and storage overhead, and dynamic batching incurs some CPU overhead.
Feature | Universal Render PipelineA series of operations that take the contents of a Scene, and displays them on a screen. Unity lets you choose from pre-built render pipelines, or write your own. More info See in Glossary (URP) |
High Definition Render Pipeline (HDRP) | Custom Scriptable Render Pipeline (SRP) | Built-in Render Pipeline |
---|---|---|---|---|
Static Batching | Yes | Yes | Yes | Yes |
Dynamic Batching | Yes | No | Yes | Yes |
Transparent shadersA program that runs on the GPU. More info
See in Glossary often require Unity to render meshes in back-to-front order. To batch transparent meshes, Unity first orders them from back to front and then tries to batch them. Since Unity must render the meshes back-to-front, it often can’t batch as many transparent meshes as opaque meshes.
Unity can’t apply dynamic batching to GameObjects that contain mirroring in their Transform componentA Transform component determines the Position, Rotation, and Scale of each object in the scene. Every GameObject has a Transform. More info
See in Glossary. For example, if one GameObject has a scale of 1 and another GameObject has a scale of –1, Unity can’t batch them together.
If you are not able to use draw call batching, manually combining meshes that are close to each other can be a good alternative. For more information on combining meshes, see Combining meshes.
Warning: When you access shared material properties from a C# script, make sure to use Renderer.sharedMaterial and not Renderer.material. Renderer.material
creates a copy of the material and assigns the copy back to the Renderer. This stops Unity from batching the draw calls for that Renderer.