# Merged meshes, multimaterials, and draw call counts

**URL:** <https://forum.babylonjs.com/t/merged-meshes-multimaterials-and-draw-call-counts/23113>\
**Category:** Questions\
**Created:** [August 16, 2021, 7:44pm UTC](https://forum.babylonjs.com/t/merged-meshes-multimaterials-and-draw-call-counts/23113 "2021-08-16T19:44:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![grundy](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@grundy](https://forum.babylonjs.com/u/grundy)\
**Post date:** [August 16, 2021, 7:44pm UTC](https://forum.babylonjs.com/t/merged-meshes-multimaterials-and-draw-call-counts/23113/1 "2021-08-16T19:44:26Z")

</div>

Is there a way to merge cloned meshes, where the original mesh has a multimaterial, and keep the draw call count constant (ie. independent of the number of clones that got merged)?

[https://playground.babylonjs.com/#NZP2SF#3](https://playground.babylonjs.com/#NZP2SF#3)

In the playground, everything is working as expected. I clone 5 cubes, each with 2 materials. If I merge with `multiMultiMaterials` false, there is 1 draw call (but 1 material). If I merge with `multiMultiMaterials` true, there are 10 draw calls (2 per pre-merged cube).

I’m hoping to find a way to merge them all into one mesh (still with 2 materials) and have 2 draw calls for the entire merged mesh.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [August 16, 2021, 11:58pm UTC](https://forum.babylonjs.com/t/merged-meshes-multimaterials-and-draw-call-counts/23113/2 "2021-08-16T23:58:23Z")

</div>

Would using instances instead of merging meshes work for your use case? I tried modifying your example with instancing and it keeps the multimaterial while having few draw calls 😃[https://playground.babylonjs.com/#NZP2SF#4](https://playground.babylonjs.com/#NZP2SF#4)

---

<div class="post-metadata">

**Author:** ![grundy](https://avatars.discourse-cdn.com/v4/letter/g/a88e57/32.png) [@grundy](https://forum.babylonjs.com/u/grundy)\
**Post date:** [August 17, 2021, 4:13am UTC](https://forum.babylonjs.com/t/merged-meshes-multimaterials-and-draw-call-counts/23113/3 "2021-08-17T04:13:20Z")

</div>

Thanks for the idea! Yes it does work. In practice I have a few hundred instances, but I was able to put them as children of a transform node and manipulate that.

I’d still be interested to know if there’s a way to do it with merged meshes.

---

<div class="post-metadata">

**Author:** ![jerome](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jerome/32/22_2.png) [@jerome](https://forum.babylonjs.com/u/jerome)\
**Post date:** [August 17, 2021, 5:15am UTC](https://forum.babylonjs.com/t/merged-meshes-multimaterials-and-draw-call-counts/23113/4 "2021-08-17T05:15:37Z")

</div>

> **[Solid Particle System Materials | Babylon.js Documentation](https://doc.babylonjs.com/divingDeeper/particles/solid_particle_system/sps_material)**
>
> Learn all about solid particle system materials in Babylon.js.

could help, maybe  
It optimizes the draw call number by sorting the geometry under the hood after the merge (the solid particles addition)
