Enable GPU instancing for a prebuilt material
Make sure meshes and shaders are compatible with GPU instancing.
Read time 1 minuteLast updated 10 days ago
To enable GPU instancing for a prebuilt materials, follow these steps:
- Select the material in the Project window.
- In the Advanced Options section of the window, enable Enable GPU Instancing.Inspector
?
If multiple GameObjects use the same mesh and material, Unity now uses GPU instancing to render them in single draw calls. To check this, open the Frame Debugger and look for render passes called Draw Mesh (Instanced).
If there's no Enable GPU Instancing property, the prebuilt shader doesn't support GPU instancing.
Change the properties of instances
To change the properties of instances at runtime, for example to give each instance a different color or position, create a script to do the following:
- Create a MaterialPropertyBlock with the property value for the instance.
- Attach the script to the Mesh Renderer component of the GameObject.
For more information, refer to MaterialPropertyBlock.
Create custom instances
To render multiple instances of a mesh in a script using GPU instancing, use one of the following APIs: