Instances performance

hey guys, can you tell me, can I boost up performance of instances in this code?

https://www.babylonjs-playground.com/#1FYRAN

It contains 50k triangles and it is too slow if compare with THREE js instances demo

https://threejs.org/examples/?q=insta#webgl_buffergeometry_instancing

image vs image

may be I have to switch on some scene optimizations?

1 Like

How about using the Solid Particle System instead?:

https://playground.babylonjs.com/#HEH3DF

2 Likes

sorry but the question was only about performance of instances. I made that simple demo just to show the problem (same faces count - variuos FPS)

Well, the comparison with the 3js example is not that fair because this example uses a dedicated vertex shader to animate the triangles.

That said, the BJS instances can be optimized. By default, each instance World Matrix, then each BoundingInfo is recomputed each frame and each instance is checked against the camera frustum.

You could then skip all these computations and update by yourself the instance world matrix buffer directly like explained here : Use Instances - Babylon.js Documentation

In the example from the documentation, you can see 20K dodecahedrons moving at a decent framerate.

That’s what I’m using in this demo : Test Babylon Instances Terrain
There are 6000 instances (each way higher poly than a triangle or a dodecahedron) whose world matrix buffers are updated by hand.

4 Likes

@jerome thank you very much!

2 Likes

perfect perf :slight_smile: https://www.babylonjs-playground.com/#WHU3S6#14

4 Likes