# GPU instantiation
# Features
In the process of drawing the scene in the mini game framework, for each MeshRenderer, a DrawCall will be generated for each SubMesh. In the case of too many objects in the scene, rendering overhead will become very large.
If there are many small objects with the same materials and same models in the scene, you can consider turning on GPU instancing to speed up rendering.
# Usage restrictions
If you want objects with GPU instantiation enabled to be put into the same DrawCall, you need to ensure:
- The material used by the objects instantiated by the GPU is the same;
- The model used by the objects instantiated by the GPU is the same;
# Instructions
# 1. Turn on the instantiation switch
On the material used by the object that you want GPU to instantiate, **check **useInstance
.
**Note: If dynamicBatch is checked on MeshRenderer, the useInstance
on the material will be invalid. *
# Second, control the rendering order of objects
You need to manually ensure that the GPU instantiated objects are rendered in a batch, and no other objects can be inserted in the batch.
The rendering order of objects in the scene is controlled by the renderQueue
on material, and objects with the same renderQueue
will be drawn in one batch. Therefore, if you want to render objects instantiated by the GPU in a batch, you need to manually modify their materials (should be the same), and set the renderQueue
to a value different from any other objects in the scene.