Model contains two children:(items:store root instanced mesh,floor: store all Room);
each room contain Collider(Collider Mesh), Item(store transformNode to create InstancedMesh),wall(Wall Mesh).
do not create anything: 65 drawcall
mesh.clone : 809 drawcall
mesh.createInstance:319 drawcall
it only has 22 root instance meshes, but drawcall increase 254
I only enable 4 roots in the rect,(4X1 mesh + 24X2 mesh +20X3 mesh +12X1mesh):total drawcall 72,increase 7, it means that this 4 roots work correctly.
but I enable the 5th root(44X3 mesh): total drawcall 105, increase 33 = 3X11 work wrong
I enable the 6th root(18X5 mesh): total drawcall 160, increase 55 = 5X11 work wrong
I enable the 7th root(4X1 mesh): total drawcall 163, increase 3 ???
I enable the 10th root(33X3 mesh): total drawcall 166, increase 3 work correctly
Hi Evgeni!
I create a playGround https://www.babylonjs-playground.com/#L1F71C#18,
line 54 to show/hide instance mesh
line 89&90 clone mesh line 91 createInstance
line 47 to set instance root (with some error)
1 mesh
DrawCall:hide:64 show(instance):171 show(clone):276
line 50 to set instance root (work correctly)
3 meshes
DrawCall:hide:64 show(instance):67 show(clone):163
The “&& shelf 1 ##33” and “&& work chair 1 ##212” meshes have a number of child mesh (respectively 34 and 213). So, when you disable one, the children won’t get drawn and the number of draw calls is decreased. The number of draw calls that is saved depends on the number of children and if there are instance meshes in those children.
Hi, only the Lod0 node is the root of Instance, else are all son instances createInstance by meshes in node Lod0. I set them parent to Lod0’s parent is only for easy to hide.
You have more draw calls than expected because some of the parent nodes of your instances have negative scaling, which inverts the determinant of the world matrix, which in the end prevents to batch the instance.
To demonstrate this, I have applied a Math.abs on the x/y/z scaling values of the nodes, and you can see you now have a single additional draw calls for all the instances: