Introduction to GPU instancing
Learn about the GPU drawing multiple copies of a mesh at the same time, for example to draw multiple trees or bushes.
Read time 2 minutesLast updated 20 days ago
GPU instancing is a draw call optimization method that uses a single draw call to render multiple GameObjects that use the same mesh and material. This speeds up rendering when you draw things that appear multiple times in a scene, for example, trees or bushes.
GPU instancing is a built-in functionality of GPUs. Each copy of the mesh is called an instance. Each instance can have different properties, such as color or scale.
The performance benefits of GPU instancing depend on the platform and the GPU. For each draw call, Unity has to collect, combine, and upload properties from various memory locations, so the performance overhead might outweigh the benefits. The performance benefits are better on mobile platforms than on desktop platforms.
Render pipeline compatibility
GPU instancing is compatible with all Unity render pipelines, with the following limitations:
- If you use the Universal Render Pipeline (URP) or High Definition Render Pipeline (HDRP), GPU instancing works with custom shaders only if you disable the Scriptable Render Pipeline (SRP) Batcher or make a shader incompatible with the SRP Batcher.
- If you use the Built-in Render Pipeline (BiRP), GPU Instancing doesn't work with Shader Graph shaders.
For information on draw call optimization methods you can use instead of GPU instancing, refer to Choose a method for optimizing draw calls.
Indirect lighting compatibility
GPU instancing supports the following types of GameObject:
- Dynamic GameObjects that get lighting from Light Probes.
- Static GameObjects that get lighting from lightmaps, if they have Contribute GI enabled in their Static Editor Flags, and they bake to the same lightmap texture.
- GameObjects that use Light Probe Proxy Volumes (LPPV). You must bake the LPPV for the entire space that contains all the instances.
Shader and mesh compatibility
The following meshes are compatible if you use prebuilt materials:
- Mesh Renderer components in your scene. Skinned Mesh Renderer components are not supported.
- Meshes you render in a script using APIs that support GPU instancing in prebuilt materials, such as Graphics.RenderMeshInstanced.
The following shaders support GPU instancing:
- Most prebuilt materials. Compatible shaders have an Enable GPU Instancing property.
- Shader Graph materials, if you use URP or HDRP.
To create a custom shader that supports GPU instancing, refer to the following:
- Creating custom shaders that support GPU instancing in the Built-In Render Pipeline
- Indirect & Procedural Rendering in Shader Graph on the Unity Discussions site if you use URP or HDRP.