Batching - Optimization for low-end PC, Mobile, and VR

Hi there,

I’m building a project that requires duplicating any of 4 templates at run time. Each template is different and has different materials.
When I run the project, I can reach up to 3000 draw calls for a maximum total of 150 duplicates.

I’m trying to batch the instances of my templates to optimize the number of draw calls but I can’t seem to get it to work. What I did is define a batch group for each of the 4 templates with a high max AABB. I then assigned their respective batch group to each template.

Launching the game I was expecting the clones of my template to all belong to the same batch group, reducing the number of draw calls, but I still get the same amout of draw calls.

Any idea of what I’m doing wrong ?

Hi @F_Sabatie,

Can you check in the profiler (use Alt + T to open it if it’s closed), what’s the batch time?

I suspect for some reason the batcher isn’t running in your scene. You can try and invoke the batcher manually after you are done spawning everything:

this.app.batcher.generate();

Hi @Leonidas ! Thank you for your fast response !

The batcher seems to be running :slightly_smiling_face:

image

I think 5.60ms is a very short time for 3000 entities. Most likely it’s not running for the full scene, likely it’s only running on start before you spawn the entities.

Try using the command I posted above, you can even execute it at any point in the browser console like this, and check if draw calls drop. If not there is some issue in your batch groups configuration I think:

pc.app.batcher.generate();
1 Like

I applied the changes you proposed once all the templates were duplicated, i did see a drop in draw calls :smiley: Although it wasn’t something major, and that’s because within all thoses templates, i had at least 4 other renderers that could not be batched. I removed these renderers and now only display them when the player is close enough to the template. Doing that I reduced the draw calls from 2700 to around 300.

Thank you so much for your help @Leonidas !

3 Likes