Dynamic Batching is an optimization technique used in rendering engines to reduce overhead on the draw calls issuing process by merging several draw calls into single one.
Dynamic Batching aims to improve performance on older and less powerful devices. However, with modern consumer hardware, the CPU workload associated with dynamic batching can exceed the benefits of minimizing draw calls, ultimately leading to a decrease in performance.
Draw Call Conditions
A single draw call is batchable if the following conditions are met:
Dynamic Batchingoption is enabled in the Playable Plugin Window.
Meshused by the draw call is indexed (uses Index Buffer).
- The draw call is not rendered using instanced rendering (e.g. particle systems are not batchable).
Skinned meshes are not batchable.
Two draw calls could be batched if the following conditions are met:
Materialinstance used by both draw calls is the same.
- The shader keywords used by both draw calls are the same.
- Both draw calls should use the same shader features (e.g. lightmaps, shadows).
- Mesh parameters/Uniforms used in rendering are the same for both draw calls.
- Sort keys are the same.
- The rendering order of the draw call could be changed without an effect on the rendered frame.
- The layout of the Vertex Buffer should be the same for both draw calls.
- Both meshes should have similar data (e.g. Position, Texture Coordinates, Color).
Dynamic Batching cannot be applied to GameObjects that have mirroring within their
For example, if two GameObjects have different scales, with one having a scale of 1 and the other having a scale of -1, they cannot be batched together. See Unity Documentation for more details.
How does Dynamic Batching work with Playable Plugin?
Playable tries to lower pressure on both CPU and GPU by not calculating batches every frame, instead it caches previously allocated batches, and recalculates them only when there is a breaking change that makes some of the batch data incorrect.
This could occur if any of the following conditions are met:
- The hierarchy of the scene has changed
- The affected batches will be recalculated.
- The vertex buffer of one or more of the instances has changed (typically happens during animations).
- The mesh parameters have changed.
However, Playable will not recalculate batches if there was any other changes. A position change, for example, reuses previously allocated batches.
Although data buffers that contain vertices and indices will remain unchanged, modifications to the transform (position, rotation, or scale) will result in changes to the Model matrix, which are then applied and updated. This approach saves rendering time while maintaining the visual integrity of the image.
- Example 1
- Example 2
- Example 3
|UI||Yes||Supports all types of Canvas UI (Overlay, Camera, World), and all built-in UI elements (Image, Text, Toggle, etc.)|
|3D||Yes||Except: Particle Systems and Skinned Meshes|
|Built-in Rendering Pipeline (BIRP)||Yes|
|Universal Rendering Pipeline (URP)||No||Dynamic Batching works only in BIRP at the moment|
|High Definition Rendering Pipeline (HDRP)||No||Dynamic Batching works only in BIRP at the moment|
Unity versions support
Dynamic Batching works on all versions of Unity that Playable can run.
Limitations and Performance Characteristics
Dynamic Batching could increase performance in some scenes, especially if the scene contains many similar objects that are close to each other in the hierarchy. For other scenes, if there are many/all different objects or similar objects scattered across the hierarchy, it does not impact performance or make it inefficient for some devices. Please, measure performance on the target devices to see the performance changes for the scene while using Dynamic Batching.
If there is a breaking change in the batch (see the previous section for details) the Playable Plugin will regenerate this batch by allocating new GPU buffers and merging meshes together. In cases where breaking changes occur frequently for many batches, performance can be worse than if Dynamic Batching wasn't used.
The amount of draw calls that could be batched together and the time to make a batch depends on device capabilities. On some low-end devices if scene contains many complex objects (complex meshes or shaders), Dynamic Batching could perform worse than regular rendering without Dynamic Batching.
Recommendations for using Dynamic Batching
- Use the same material for multiple objects.
- Keep similar objects close in the hierarchy.
- Animated objects should be separated from non-animated objects in the hierarchy.
- Try to group objects in the hierarchy the same way as described in the above.
- See conditions for when two draw calls could be batched.
- Measure the playable performance on the target device.
If Dynamic Batching is negatively impacting performance or resulting in distortions in the final image, it is recommended to turn it off.
Please report any issues with Dynamic Batching to our support team via Creative Suite Intercom.
- Open a project of your choice.
- Import the Playable Plugin plugin.
- Create or open existing scene.
- Add batchable objects to your scene.
- see our supported features for Dynamic Batching to check what objects are batchable.
- Open the Playable Plugin Window and enable Dynamic Batching:
- Check Settings → Advanced → Dynamic Batching option
- Export the project and test the results:
- You can make sure batching is working by taking a look at the frame debugger (See the spector argument documentation). In the captured frame you could see that some of the draw calls are rendering several objects (use scene with disabled Dynamic Batching for comparison).
- You can also toggle Dynamic Batching in runtime, and measure performance, for that you could use built-in fps counter. See FPS Counter.