When is InstancedMesh worth it in THREE?

Im my project I have about 20-30 different objects with the same geometry and same materials. And I will probably test out is it worth is for me later today. But I was just wondering generaly is there maybe a rule when is InstancedMesh worth it or you just test it out and see if you gain performance or not ?

Most of the time when you have a lot of repeating geometries. Keep in mind, meshes usually contain more than one geometry which makes instancing suddenly more complicated than it may be worth. They are also quite very hard to animate and relatively hard to update.

From experience, you’d most likely use instancing for static things like buildings / rocks / grass / clouds. More complex things are only further complicated by applying instancing to them.

2 Likes

Generally, for 20-30 objects most likely you will not notice any performance boost by using InstancedMesh.

But it is OK to try it with various number of objects, e.g. 10, 100, 1000, 10000. Thus you will feel the effect of instancing.

2 Likes

With InstancedMesh you lose frustum culling (unless you manually update the bounding box.). In a lot of cases that doesn’t matter since your app may show ALL your instances at some point anyway, and if that works well enough, then we can afford the hit of ignoring frustum culling. Additionally… when you have LOTS of things, it can be cheaper to take the frustum culling hit, than trying to compute the bounding box in javascript. (Scenarios like gpu driven behaviors or particles systems where you Can’t compute the bounding box since the data is living on the GPU, and reading it back is slower than just taking the frustum culling hit…) So it’s a balance that you develop a sense for over time/experience.
I personally, usually consider it I have more than 1 of something, and I plan to have more than 10. If I’m just prototyping an idea, I’ll usually skip it, knowing that if the prototype works out, then the idea will be potentially even more viable, after a rewrite with instancing reduces the drawcall pressure.

But if that Thing is by itself a complex mesh > 10k triangles, then you have to consider that you’ll be pushing 10k * number of instances triangles, in which case you may hit vertex processing limits before the instancing even kicks in.

It’s a balancing act.

1 Like