This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
static_batching [2021/05/02 16:18] 167.114.64.97 old revision restored (2021/03/20 22:26) |
static_batching [2021/12/12 23:11] starasgames Added a bit of informaton about how static batching works in Editor |
||
---|---|---|---|
Line 16: | Line 16: | ||
Instead, the performance comes from issuing fewer material / mesh change state operations (in OpenGL at least). In a lot of ways, this ends up being more similar to SRP [[Dynamic Batching]]. | Instead, the performance comes from issuing fewer material / mesh change state operations (in OpenGL at least). In a lot of ways, this ends up being more similar to SRP [[Dynamic Batching]]. | ||
+ | |||
+ | Static batching is done at build-time, so mobile developers should be aware that static batching can unexpectedly increase your build size. Static Batching can result in significantly more mesh data being generated, if many batch meshes are created. | ||
+ | |||
+ | In the Editor static batching occurs after the scene is loaded (after Awake and OnEnable). It is considered a [[https:// | ||
==== Lightmap UV Coordinates ==== | ==== Lightmap UV Coordinates ==== | ||
Line 21: | Line 25: | ||
The lightmap coordinates from [[lightingdataasset|Lighting Data Asset]] are baked into the Combined Mesh UV coordinates when the scene loads((I think this also happens **during** standalone build, not at runtime, but I'm not sure)). Afterwards, querying '' | The lightmap coordinates from [[lightingdataasset|Lighting Data Asset]] are baked into the Combined Mesh UV coordinates when the scene loads((I think this also happens **during** standalone build, not at runtime, but I'm not sure)). Afterwards, querying '' | ||
+ | Static batching can actually work with manually provided lightmap scale/ | ||
+ | |||
+ | ===== Batching and MaterialPropertyBlocks ===== | ||
+ | |||
+ | Static and SRP batching is incompatible with MaterialPropertyBlocks, | ||
+ | |||
+ | This is the data sent by the SRP batcher for each draw call: https:// | ||
+ | |||
+ | This data is efficiently managed by the engine and uploaded to the GPU as fast as Unity can. The idea is to abuse some of these built-in values to pass custom data. Good candidates are '' | ||
+ | |||
+ | When using SRP batching, the recipe is following: | ||
+ | |||
+ | '' | ||
+ | |||
+ | '' | ||
+ | |||
+ | |||
+ | For custom SRPs: '' | ||
+ | |||
+ | On the GPU you should have a '' | ||
+ | |||
+ | |||
+ | Note that the " |