Hello guys, in this article I will gonna cover on difference between static and dynamic batching, what is batching, its advantage and disadvantages and how we can use batching in unity. To know all these answers, read this article to end.
What is batching in unity ?
In unity, a batch is merging or combination of package of data or group of draw call that will be sent to GPU.
Advantage and Disadvantages of batching in unity
The advantage of batching in unity is to reduce draw call produced by unity to render any game object on screen. The batching is considered as one of best performance optimization technique.
Static batching is very fast in performance but consume more memory, on the other hand dynamic batching consume less memory but it is not fast in performance as static batching in unity.
Difference between static and dynamic batching in unity
Both static or dynamic batching is merging mesh to form a bigger mesh but there is only one difference in both and that is in static batching a batched mesh is rendered once with same transform ( position, rotation and scale ) while in dynamic batching a batched mesh is rendered multiple times with multiple transforms but in both cases data is sent once to GPU.Let's explain with example, a static batch of 50 game objects with 1000 polygons each will result in sending 50,000 polygons to GPU to rendered once, similarly for dynamic batch of 50 game object of 1000 polygons for each game object will send 1000 polygons to GPU but it will ask to render for 50 times, see the difference.
Limitation of static batch in unity
1. Game object with static batch should not be rotated, scaled, position updated and enabled or disabled otherwise it will hit your gaming performance in unity.
2. There is limit for batching mesh in vertices in static batch and that is unity can batch ~15k vertices max for static batching otherwise unity will create new batch.