[SOLVED] Batching for render assets with multiple mesh instances

In the example project the render asset has 3 mesh instances and a material assigned to each one. So that’s 3 draw calls per house. There doesn’t appear to be a way to assign a different batch group to each mesh instance, so if I have a lot of houses in the scene I cannot reduce the draw calls. Does the model need to be created differently so that it imports with multiple render assets each with only 1 mesh instance?

https://playcanvas.com/project/944013/overview/batch-question

Hi @Kulodo133,

Since each mesh instance uses its own material, than that’s a unique draw call no matter how you structure your model.

If all three mesh instances were using the same material, then the batcher would pick that up and batch them into a single draw call.

Hi Leonidas

Yes, so if I want reduce the draw calls when I have many houses in the scene then what should we do for such a model? We’re not going to set the same material on each mesh instance. The editor render component UI does not allow to set different batch groups for each mesh instance. Maybe it should , although I don’t know if that is even possible to support in the engine. If I restructure the model so that there are multiple render assets each with only one mesh instance and unique material then couldn’t I assign each render component to a separate batch group. Then if I had 100 houses there should be only 3 draw calls rather than 300. It seems like this should be a common problem that people have?

You don’t have to assign a batch group per mesh instance. You assign it to the render component and internally the PlayCanvas batcher will take care to group the the mesh instances on the required batch groups to reduce the draw calls to the minimum required.

If you have a model with 10 mesh instances, 7 of them use the same material, then those 7 mesh instances will be grouped in a single draw calls.

A good advice is to prepare your models to reuse the same material wherever it’s possible. If you are looking for at getting as low draw calls as possible search for texture atlases and how those are used.

It’s a practice where you pack multiple low res textures on the same material and then you unwrap your model to use the part of that texture that it’s required. That way you can have unique textured surfaces that use the same material/texture. The batcher will be kind enough to group all those mesh instances into a single draw call.

1 Like

HI Leonidas

Sorry to waste your time :grimacing:, Actually batching does work correctly in my example project. I was just misunderstanding it for models with multiple mesh instances. Your explanation helped me see the light.

1 Like