Instances and culling

I was thinking about how I could optimize some scenes and I thought that using instancing might be a good way to deal with some of the performance I want to do.
But I was wondering about the culling behavior.

I am assuming that instances it self is not culled.
If the master object goes out of frustrum does it also cull the instances even though the instances might be in view?

Same goes for occlusion culling.
Does babylonjs by default do occlusion culling?
If it does and the master object is occluded but some instances are visible, will it still be culled?

1 Like

Nope, that would negate the advantage of using them :slight_smile:

I have disabled the original mesh in this playground, but the instances are still showing -

@sebavan can help further for sure :slight_smile:

1 Like

Ahh, excellent, thank you for your effort.
I was pondering about how to efficiently build environments on the web.
Take walls for example, it will be great if you can download a single mesh that represents a wall part and use instancing to follow a path drawing the actual wall.
This means less data to download and much memory to use but I suppose you might need to use a mesh per wall with instances filling the length of that wall.
In that way if the mesh and instances are behind the camera, those will be excluded from the render graph.

I am not 100% sure how this will be affected with octrees but I am certainly interested in testing it further :slight_smile:

Am I correct in assuming that active meshes are items that will be drawn.
I did a test and found that sometimes I get some odd results about what meshes are active when when not.

We have a bit of offset around the meshes to prevent popping effects and such which might impact the result

Am I correct in assuming that active meshes are items that will be drawn.

Yes, active meshes are the meshes that camera will render. I remember it also affects the instances in my project. E.g. If the original mesh is not active, the instances are not rendered.

Since I need almost all the meshes all the time in my project, all my meshes has:

mesh.alwaysSelectAsActiveMesh = true;