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

  • Unity Game Optimization
  • Dr. Davide Aversa Chris Dickinson
  • 472字
  • 2021-06-24 12:13:09

The Benefits of Batching

In 3D graphics and games, batching is a very general term used to describe 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 the 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 the 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 why 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, thereby rendering it 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 an improvement in performance. 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 see, 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
主站蜘蛛池模板: 成安县| 轮台县| 辽宁省| 乌什县| 呼图壁县| 肇源县| 德昌县| 西平县| 莲花县| 太原市| 眉山市| 清丰县| 阳城县| 买车| 乌什县| 寻甸| 泰来县| 香港| 大化| 天门市| 常熟市| 富蕴县| 东乌珠穆沁旗| 谢通门县| 什邡市| 城步| 万宁市| 赫章县| 衡水市| 炎陵县| 丰原市| 崇义县| 云梦县| 西林县| 昌都县| 富平县| 晋中市| 宁海县| 莱芜市| 临澧县| 长寿区|