Instance Batcher is a mesh batching solution that will help you reduce draw
calls when using large number of
prefab instances.
Documentation
Please visit the Forum if you have any questions.
========== Features ==========
Requires almost no change in workflow.
Reduces draw calls by batching larger number of instances of a single mesh, while still allowing dynamic use of individual instances.
No vertex limit on the original mesh
(vertex limit of 65534 vertices per Mesh still applies)
Allows dynamic changes to:
- Transform component
- MeshRenderer component properties:
- shadow casting mode
- receive shadow
- material
- shared material
Allows setting per instance color (RGBA).
Dynamic renderer bounds calculation for each batch (render only visible batches).
Changes are applied in LateUpdate.
Modified Standard shaders:
- Metallic and Specular workflow
- Forward and Deferred render path
- Directional, Point and Spot lights
(with shadows and cookies)
- using per instance color
Easy to use InstanceBatcher_Utils.cginc for adding instancing support to custom shaders:
- Includes basic instructions
- Simple custom shader provided as a sample
Editor Tool for generating Instance Batcher Prefab.
Source code included.
=== Requirements and Limitations ===
Target device must have support for:
- Shader Model 3.0
- TextureFormat.RGBAFloat
InstanceBatcher_Utils.cginc works only with vertex/fragment shaders.
Does not support per instance culling.
Does not support multiple materials or sub-meshes on a game object with InstanceController component attached.
Does not work with light probes and/or reflection probes.
Does not support SkinnedMeshRenderer
Does not support LOD Group
Modified Standard shaders do not support parallax.
Things that will make instance not batch with others and will create a new batch:
- Each combination of MeshRenderer's shadow casting mode and receive shadow will create a separate batch.
- MeshRenderer's material property behaves as normal and will produce a new material, which means that it won't batch with other instances.
- Adding new instance when the capacity of the largest batch is reached will produce a new
batch of smallest capacity.