Implementation of Three js' batch mesh in Babylon js

I was trying to implement batch mesh of three js into babylon js, which lets you draw different geometries with same material into single draw call. I have managed to port the initial version of it. But it would be cool to have it core the way it is in Three js using webgl multi draw extension

Live version : https://babylon-batch-mesh.vercel.app/
github : GitHub - bhushan6/babylon-batch-mesh: Three js' Batch mesh implementation in Babylon js

4 Likes

Have you seen Solid Particle System?

https://doc.babylonjs.com/features/featuresDeepDive/particles/solid_particle_system/sps_intro

1 Like

Didn’t know it supports different geometries? does it also uses muti-draw extension?

@Bhushan_Wagh Just to clarify: say I have a low poly game. All the level objects (plants, boxes, walls, doors, etc.) share the same (palette) material.

Multi draw means I can leave all these level objects as individual meshes and still only need one draw call. Is that right?

Also, can I add and remove individual meshes to the multi draw call?

Also also, can some of the multi draw meshes be animated?

it will be single mesh with single draw call but you can animate single instances of the meshes

Super cool! Wondering whats the upper bounds on this? With the SPS system depending on the geometry it will crash around 200k polyhedrons. Could test this quickly if you uncap your slider in the demo.

I guess mine won’t be able to handle that much, since I am recreating meshes, instead of reusing them That would be bottleneck, sps has great api to handle that, it takes number of copies to add with mesh. But while testing I tried around 55k static instances and was working fine and 20k animated instances on each frame.

1 Like

If anyone wants to play with it too: Babylon.js Playground

1 Like

I was trying to test performance against SPS, I updated the example, so you can test it too. But bit weird thing is SPS updates transformation really well if it has just multiple copies of one mesh only but starts degrading in performance when you have multiple copies of multiple meshes. I add way to check that to in demo.

1 Like