static_batching
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
static_batching [2021/12/11 21:46] – [Batching and MaterialPropertyBlocks] guycalledfrank | static_batching [2025/01/15 04:35] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 27: | Line 27: | ||
===== Batching and MaterialPropertyBlocks ===== | ===== Batching and MaterialPropertyBlocks ===== | ||
- | Static and SRP batching is incompatible with MaterialPropertyBlocks, | + | Static and SRP batching is incompatible with MaterialPropertyBlocks, |
- | This is the data sent by the SRP batcher for each draw call: https:// | + | This is the data sent by the SRP batcher for each draw call: |
+ | |||
+ | {{ :: | ||
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 '' | 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: | + | An example, when using SRP batching: |
- | + | ||
- | '' | + | |
- | + | ||
- | '' | + | |
- | + | ||
- | + | ||
- | For custom SRPs: '' | + | |
- | <br> | + | |
- | On the GPU you should have a UnityPerDraw cbuffer with float4 unity_DynamicLightmapST in it, and it will be filled with custom data. | + | <code csharp> |
+ | renderer.realtimeLightmapIndex = 0; // forces " | ||
+ | renderer.realtimeLightmapScaleOffset = ...; // Vector4 of custom data | ||
+ | // For custom SRPs: | ||
+ | // (Only relevant for custom SRPs; in existing RPs it should likely just work as is, as they all support lightmapping in the main pass) | ||
+ | drawingSettings.perObjectData = ...; // PerObjectData.Lightmaps or otherStuffYouNeed; | ||
+ | </ | ||
- | Note that the " | + | On the GPU you should have a '' |
static_batching.1639259165.txt.gz · Last modified: 2025/01/15 04:35 (external edit)