What are the Differences Between Hardware Instancing and Batching in PlayCanvas?

Seeking clarity on hardware instancing and batching in PlayCanvas? Learn the key differences between these techniques and understand why and when to use each for improved rendering performance.

perhaps these can help?
https://developer.playcanvas.com/en/user-manual/optimization/hardware-instancing/
https://developer.playcanvas.com/en/user-manual/optimization/batching/

When it comes to performance/lowering the number of draw calls:

  • HW instancing allows you to render multiple instances of the same model (mesh + material) in a single draw call. It’s great when rendering large numbers of the same model and it allows you to easily update each instance (position/rotation/scale) and even have custom attributes per instance (e.g. different color per instance, requires modifying a shader chunk). With HW instancing you can even update the buffer on the fly and add/remove instances.

  • Batching is similar to joining your models in Blender, or any other modelling app. It can lower the draw calls even more in some scenarios when compared to HW instancing, for example when having different models that share the material, you can still get a single draw call.

Dynamic batching allows you to move your objects (position/rotation/scale) but it comes with some limitations (maximum number of movable mesh instances. This hardware dependent but has a maximum of 1024 per batch) and possible performance cost (it uses bones/skinning to move the instances). Also right now dynamic batching will not support any shader chunks you may be overriding (there is a workaround by patching the engine).

With batching it’s not easy to update your batch groups on runtime so if you are planning to do LODs or more complex than AABB visibility culling, HW instancing is easier to work with.

Hope that helps as a starting point!

4 Likes

Thank you so much! @Leonidas Does batching support frustum culling while hardware instancing does not, right?

So, yes with batching you can set an AABB and split your objects to multiple batches (that potentially increases the draw calls), to get basic frustum culling working.

With instancing there isn’t any automatic frustum culling (there is a feature request to implement some), so you will need to handle it on your own. But if you implement that by updating the instancing buffer, it will not affect/increase your draw calls.

1 Like