Hello, it’s my first DevLog post with the intention of bringing some crazy experiments.
The GPU instancing allows you to draw many instances of the same mesh using an instanced shader in a single draw call, while still allowing a per-instance data set, including position, rotation and color, something that static batching does not allow.
Using GPU Instancing we have over 1900 saved by batching with hundreds of dynamic objects of different colors. GPU Instancing is life!
When the CPU is the factor limiting your framerate, instancing can provide a significant performance benefit. To enable instancing on the Standard Shader, tick the Enable Instancing checkbox on the material settings. Alternatively, you can manually add instancing support to your own shaders.
Adding per-instance data
Even though the instanced GameObjects are sharing the same Mesh and Material, you can set Shader properties on a per-object basis using the MaterialPropertyBlock API. In the example below, each GameObject is assigned a random color value using the _Color property:
Adding instancing to your own shaders
The following example takes a simple unlit Shader and makes it capable of instancing:
The GPU instance feature is available from Unity 5.4.
Here’s an example with standard shader on my github.
See you next time.