Dynamic batching is a draw call batching method that batches moving GameObjects to reduce draw calls. Dynamic batching works differently between meshes and geometries that Unity generates dynamically at runtime, such as particle systems. For information about the internal differences between meshes and dynamic geometries, see Dynamic batching for meshes and Dynamic batching for dynamically generated geometries.
Note: Dynamic batching for meshes was designed to optimize performance on old low-end devices. On modern consumer hardware, the work dynamic batching does on the CPU can be greater than the overhead of a draw call. This negatively affects performance. For more information, see Dynamic batching for meshes.
This section includes information about the render pipeline compatibility of dynamic batching.
功能 | 内置渲染管线 | 通用渲染管线 (URP) | 高清渲染管线 (HDRP) | Custom Scriptable Render Pipeline (SRP) |
---|---|---|---|---|
Dynamic Batching | 是 | 是 | 否 | 是 |
Unity always uses dynamic batching for dynamic geometry such as Particle Systems
To use dynamic batching for meshes:
If your project uses URP, the Scriptable Render Pipeline (SRP) batcher is enabled by default. To enable dynamic batching instead, go to the URP Asset and enable Dynamic Batching.
Unity automatically batches moving meshes into the same draw call if they fulfill the criteria described in the common usage information.
Dynamic batching for meshes works by transforming all vertices into world space on the CPU, rather than on the GPU. This means dynamic batching is only an optimization if the transformation work is less resource intensive than doing a draw call.
The resource requirements of a draw call depend on many factors, primarily the graphics API. For example, on consoles or modern APIs like Apple Metal, the draw call overhead is generally much lower, and often dynamic batching doesn’t produce a gain in performance. To determine whether it’s beneficial to use dynamic batching in your application, profile your application with and without dynamic batching.
Unity can use dynamic batching for shadows casters, even if their materials are different, as long as the material values Unity needs for the shadow pass are the same. For example, multiple crates can use materials that have different textures. Although the material assets are different, the difference is irrelevant for the shadow caster pass and Unity can batch shadows for the crate GameObjects in the shadow render step.
In the following scenarios, Unity either can’t use dynamic batching at all or can only apply dynamic batching to a limited extent:
The following renderers dynamically generate geometries, such as particles and lines, that you can optimize using dynamic batching:
Dynamic batching for dynamically generated geometries works differently than it does for meshes:
This approach is similar to how Unity submits draw calls for static batching.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.