Introduction to dynamic batching
Enable dynamic batching

How Unity batches moving GameObjects

Dynamic batching for meshes works by transforming all vertices into world space on the CPU, rather than on the GPU. This means dynamic batchingAn automatic Unity process which attempts to render multiple meshes as if they were a single mesh for optimized graphics performance. The technique transforms all of the GameObject vertices on the CPU and groups many similar vertices together. More info
See in Glossary
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 GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary
in the shadow render step.

Dynamic batching for dynamically generated geometries

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:

  1. For each renderer, Unity builds all dynamically batchable content into one large vertex buffer.
  2. The renderer sets up the material state for the batch.
  3. Unity then binds the vertex buffer to the GPU.
  4. For each Renderer in the batch, Unity updates the offset in the vertex buffer and submits a new draw call.

This approach is similar to how Unity submits draw calls for static batchingA technique Unity uses to draw GameObjects on the screen that combines static (non-moving) GameObjects into big Meshes, and renders them in a faster way. More info
See in Glossary
.


对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答
Introduction to dynamic batching
Enable dynamic batching
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961