Scene performance (heavy meshes, faces, instancing, picking)

Hi!
I have a scene with the following goals:

  • it contains heavy meshes (e.g. 5 000 000 vertices each);
  • each mesh has a big amount of faces (grouped facets);
  • there is meshes hierarchy through parent-child;
  • ability to highlight entire mesh and each face separately on mouse over;
  • create a lot of copies of mesh;
  • change mesh position / rotation / scaling.

Firstly, I used meshes with submeshes for each face. In this case i have many draw calls (one draw call for submesh). So, camera rotates slow, but it is easy to create copies, highlight entire mesh and separate faces and using mesh octrees selection works very fast.

Secondly, I created only one mesh without submeshes for faces, but stored faces as mesh metadata. In this case only one draw call for mesh. So, camera rotates quickly, easy to create copies. Face highlighting using ShaderMaterial (i pass face facets indices to shader and color this facets, but max size of arrays in shader has length limitations and depends on hardware, so it can be face with huge amount of indices, which length is bigger than shader max array size). Also i can use mesh.subdivide() + createOrUpdateSubmeshesOctree() - faster picking, but it can be many draw calls if i then create many copies of that mesh.

Thirdly, I used Solid Particle System, where each particle is a mesh face. In this case only one draw call (fast camera), easy to pick entire mesh and faces separately, but when i use mesh.subdivide() + createOrUpdateSubmeshesOctree() to improve picking, picking particle is not working. At the same time when creating mesh copy, I need to create new SPS and it can be slow if i have many mesh faces.

What is the best performance approach for my scene configuration?

1 Like

You have a scene running with many copies of a mesh with 5 million vertices and it is easy to pick entire mesh and faces separately. What sort of computer are you using? I would like to see that running but my laptop couldn’t handle it. A video would be the next best thing.

You might be interested in commenting on Faster Ray Intersects Mesh For Those with Many Facets

@JohnK Below is 150,000 cubes and 1.8M triangles. Animated. WebGPU test done in Three. I’m showing steady 120fps in Chrome on 3070 under Win11. Anyone running similar tests in Babylon to compare?

Welcome aboard!

You could do the same thing with thin instances in Babylon.js. In any case, the problem outlined in this thread is mesh picking, which is different from drawing a lot of meshes.