Understanding Batching in Unity ⌚

Djordje Vuckovic
2 min readJan 26, 2024

--

Batching is a crucial optimization technique in Unity that aims to reduce the number of draw calls required to render objects in a scene. By combining multiple meshes into a single draw call, Unity can significantly improve rendering performance and efficiency.

Here are some great batching techniques I use in my development.

Static Batching:

Static batching is ideal for objects in the scene that do not move or change over time, such as terrain, buildings, or static props. Unity automatically combines these static objects into larger meshes during the baking process, resulting in fewer draw calls at runtime.

Dynamic Batching:

Dynamic batching is suitable for smaller objects or those with dynamic properties, such as character models or interactive elements. Unity dynamically batches these objects at runtime by transforming them into vertices and grouping them based on similarity. This allows Unity to render them together in a single draw call, optimizing performance without sacrificing flexibility.

GPU Instancing:

Imagine you have a forest scene in your game with thousands of trees. Instead of loading and rendering each tree individually, which can be inefficient and taxing on system resources, GPU instancing allows you to treat the entire forest as a single mesh. This means that all the trees in the forest are rendered together in a single draw call, significantly reducing CPU overhead and improving rendering performance.

With GPU instancing, you can efficiently render large numbers of identical objects, such as trees, rocks, or other environmental elements, by specifying their positions, rotations, and scales dynamically. This approach not only optimizes memory usage but also allows for the rendering of diverse and complex scenes with minimal performance impact.

How to optimize batching:

Optimizing it can be trickier.

You should ensure that meshes are efficiently constructed with minimal vertices to maximize efficiency.

Having multiple objects in one scene with the same material is a great opportunity to optimize your game. Combining these objects that share the same material can improve rendering performance.

Probably the easiest to implement in Unity, Level of Detail on which I’ll dive deeper in tomorrow’s post!

If you like what you read, give me a follow, and drop a comment on how you manage batching in Unity.

Thanks for reading today’s dev-insight see you tomorrow at the same time!

Stay awesome! ✨

Batching in Unity

--

--

Djordje Vuckovic

Hey there! I'm Đorđe, and I'm helping you and myself become better Unity game developers. Let's connect on LinkedIn: @DjordjeVučković