[SOLVED] Does the engine do batching automatically

I made a template (of a piece of cloud) in my project and placed it anywhere on the sky. Batch group did not work on the template because it was using a custom shader, but I found that the drawcalls did not increase when clouds increased. Did the engine do something for me automatically?

The template: PlayCanvas | HTML5 Game Engine

I found that only the cloud on screen will increase the drawcalls. If I place the cloud regularly and keep a certain amount of cloud templates on screen, the drawcalls may keep in a low level.

Hi @Aryous,

No the engine will not batch automatically. For that you need to create batch groups and assign them on your models.

Most likely what’s happening here is frustum culling, which is an optimization that the engine does internally to avoid rendering models that aren’t in view.

1 Like

Hi @Leonidas and Thank you!
I will try to read the source code of material chunks and create batch groups with the custom-shader material.

For static batching, you can use your own custom shaders on batched geometry.

But for dynamic batching you do indeed need shader support. I’m not sure if it’s doable to add support on a custom shader, normally you will be overriding a standard material using shader chunks.

In any case here are the required shader chunks for dynamic batching to work:

Another option is to use Hardware Instancing for your dynamic geometry:
https://playcanvas.github.io/#/graphics/hardware-instancing