官术网_书友最值得收藏!

The Benefits of Batching

In 3D graphics and games, batching is a very general term describing the process of grouping a large number of wayward pieces of data together and processing them as a single, large block of data. This situation is ideal for CPUs, and particularly GPUs, which can handle simultaneous processing of multiple tasks with their multiple cores. Having a single core switching back and forth between different locations in memory takes time, so the less this needs to be done, the better.

In some cases, the act of batching refers to large sets of meshes, vertices, edges, UV coordinates, and other different data types that are used to represent a 3D object. However, the term could just as easily refer to the act of batching audio files, sprites, texture files, and other large datasets.

So, just to clear up any confusion, when the topic of batching is mentioned in Unity, it is usually referring to the two primary mechanisms it offers for batching mesh data: Dynamic Batching and Static Batching. These methods are essentially two different forms of geometry merging, where we combine mesh data of multiple objects together and render them all in a single instruction, as opposed to preparing and drawing each one separately.

The process of batching together multiple meshes into a single mesh is possible because there is no reason a mesh object must fill a contiguous volume of 3D space. The Rendering Pipeline is perfectly happy with accepting a collection of vertices that are not attached together with edges, and so we can take multiple separate meshes that might have resulted in multiple render instructions and combine them together into a single mesh, thus rendering it out using a single instruction.

There has been a lot of confusion over the years surrounding the conditions under which the Dynamic Batching and Static Batching systems activate and where we might even see a performance improvement. After all, in some cases, batching can actually degrade performance if it is not used wisely. A proper understanding of these systems will give us the knowledge we need to improve the graphics performance of our application in significant ways.

This chapter intends to dispel much of the misinformation floating around about these systems. We will observe, via explanation, exploration, and examples, just how these two batching methods operate. This will enable us to make informed decisions, using most of them to improve our application's performance.

We will cover the following topics in this chapter:

  • A brief introduction to the Rendering Pipeline and the concept of Draw Calls
  • How Unity's Materials and Shaders work together to render our objects
  • Using the Frame Debugger to visualize rendering behavior
  • How Dynamic Batching works, and how to optimize it
  • How Static Batching works, and how to optimize it
主站蜘蛛池模板: 宁城县| 云梦县| 鞍山市| 和顺县| 牙克石市| 临武县| 肇东市| 彰武县| 达拉特旗| 黑水县| 阳东县| 嘉禾县| 抚顺市| 凯里市| 襄垣县| 海安县| 专栏| 宜黄县| 白水县| 武清区| 东至县| 安龙县| 曲松县| 高碑店市| 湘乡市| 百色市| 丰都县| 东乡县| 崇州市| 株洲市| 西充县| 略阳县| 广安市| 尉氏县| 云霄县| 宁海县| 石城县| 林口县| 高雄市| 犍为县| 分宜县|