Disable rendering of certain InstancedMesh and BatchedMesh instances

Hi all!

I have the following problem:

My app renders a graph that can have many nodes/symbols. Let’s say more than 200k. To render it I use InstancedMesh and BatchedMesh (BatchedMesh for the links between symbols).

Before the instances are used and positioned they are all at (0, 0, 0) position. Well, the big problem I found is that when they are in the same position, or a close one, stacked on top of each other, the GPU usage goes to 100% and the frame rate plummets, no matter how good the GPU is. When the instances are positioned elsewhere the performance of the app is perfect.

I can’t juggle with the instance count (drawRange) as that would mess the index of many datatextures and instanced attributes I use for several effects in my shaders. Also would be too performance intensive to do it, javascript just can’t keep up.

So, what can I do to say: “skip this instance from rendering, don’t touch the rest” ?

Thx!

If all the instances are in the same position, you will probably have an overdraw problem.

With BatchedMesh you can hide the instances.

If you want to do the same with InstancedMesh, you can use my InstancedMesh2 library.

1 Like

BatchedMesh has the option to disable visibility for specific instances explicitly, but InstancedMesh currently does not. Scaling instances to 0, rather than overlapping their positions, should avoid the overdraw problem.

1 Like