Tested with: 2020.1.0b16.4138 + URP 9.0.0-preview.38, Windows DX11
Objects with same material & same property values
SRP batcher ON material GPU instancing OFF | SRP batched |
SRP batcher ON material GPU instancing ON | SRP batched (because if SRP batcher is ON, gpu instancing will be ignored) |
SRP batcher OFF material GPU instancing ON | GPU instanced |
Objects with different material & different property values
SRP batcher ON material GPU instancing OFF | SRP batched |
SRP batcher ON material GPU instancing ON | SRP batched (because if SRP batcher is ON, gpu instancing will be ignored) |
SRP batcher OFF material GPU instancing ON | Not batched nor instanced (expected because they are different materials) |
Objects with same material & different property values set by MaterialPropertyBlock
SRP batcher ON material GPU instancing OFF | Not batched nor instanced (because MPB values are not same) |
SRP batcher ON material GPU instancing ON | Not batched nor instanced (same as above) |
SRP batcher OFF material GPU instancing ON | Not batched nor instanced (because properties are non-instanced) |
According to Unity Documentation about GPU instancing, user can use MaterialProperyBlock to have different material properties for each instances.
Apparently the test showed that this is not true anymore in Universal Render Pipeline.
Reason:
URP shader properties are all wrapped by SRP batcher macros “CBUFFER_START(UnityPerMaterial)”.
GPU instancing need to use this macro “UNITY_INSTANCING_BUFFER_START(MyProps)”
Solution: