Best way to limit number of draw calls(batching mashes with the same material but different UVs)

I wondering that is the best way to batch meshes to draw them with one draw call. Meshes move separetly, share the same material but with different UVs. Currently i’m changing UV in this way:

mesh.updateVerticesData(VertexBuffer.UVKind, uvs)

Is there any batch mechanism in babylon, for example so assign some batchGroupId or something?

Instances can be used if you have different location but everything else is the same.

You can still use Mesh.MergeMeshes to gather all meshes into one geometry and it will be rendered in one call

Unfortunately, this wont work cause i need to have possibility to move separate meshes and display different part of big texture for each mesh(controlling UVs)

Yep so in this case you cannot batch :frowning:

But I have a plan to let users define more than the world matrices as difference.
If you want, you can give me a repro in the PG and I will use it to improve our instance support to let users change uvs as well

This is the code i test locally but don’t know how to load files in PG to not be blocked by cross-origin policy

EDIT: updated PG link

One more comment, in general i’m trying to simulate 2D sprites but maybe i’m doing sth wrong. I used this approach cause i figured that sprites are kind limited compared to mesh(ie. cannot give them parent). I very like Babylon but would love it for a bit better support for 2D :slight_smile:

Using External Assets - Babylon.js Documentation :wink:

PG fixed - :slight_smile:

Here is the issue to track progress: Add support for additional streams for isntancing · Issue #6927 · BabylonJS/Babylon.js · GitHub

Ok! Now it is possible to have specific buffers per instance:

Instances are no more limited to only different world matrix per instance. We could add other buffers as well :wink:


this is also what the SPS does, CPU side : Solid Particle System - Babylon.js Documentation

Cool thanks a lot @Deltakosh @jerome. will test it over the weekend.
Btw, what your thoughts about adding high level API for such batching. i.e mesh.batchId = XXX. And all meshes with same id(if they have same material) are batched togheter?

Any plan to provide more abstraction for the final user about instance extra properties (colors, uvs) than using manually a VertexBuffer ?
something like :
instance.color (Color4),

a bit the same way these properties are set in the SPS for example.

[EDIT] it seems that’s what they did it, by our neighbourg three-instanced-mesh - npm
Well, until now, they haven’t got a real instancedMesh, just some low level instancedBufferGeometry to manage manually.

It was not my plan but if you are OK to push a PR about it I will gladly merge it

Unfortunately, I can’t for now : still too busy with my own work … and still two missing features (coming soon, I hope) to add to the SPS. Plus the doc of all of this.

OK I can do it then:) no worries


Hello, Thank you guys, i really appreciate. I think hight level API is very useful if you start with new tech and want to R&D it to check if fits our needs.

1 Like

will work on a demo for the new API, I think you’re going to like it :wink:


Here we are!


yeeeaaaahh :blush: