How to set the LoD-distance accroding to the actuall FPS?

My OSM viewer could show endless objects but is limited by the users GPU of course. Week GPUs should get “loaded” with less objects or objects with less details.
The function addLODLevel works fine mostly. I would like to set the LoD distance according to the actual FPS. But how?
I could removeLODLevel and again addLODLevel to change the distance, could I? But it would reload the whole mesh, wouldn’t it?
Or is there an other access to the distance value? Or could BJS get this as a new feature?

I do have quite some meshes using LoD. Changing them all cyclically is a bit odd.
Could the GPU use references to a common value from multiple meshes? So I could change only this value?

1 Like

I haven’t tried this myself, but I think you should be able to put custom LOD selection using this API: Mesh.onLODLevelSelection

:thinking:
onLODLevelSelection is a trigger when the limit is crossed.
I need to change/set the distance-limit.

1 Like

Yes, you are right. I was skimming the code and there is this function that should allow you to put a custom handler.

Scene.customLODSelector

1 Like

I see. This way I could code a dynamic “distance”. My calback-code had to calculate the distance itself and could set the mesh in/visible. - Thanks @bghgary.
No example, only one PG, a useless two-liner not running anyway. I will make one.

I expected the GPU is doing the compares for my hundreds of meshes and un/hiding in each render cycle. But if a customLODSelector exists, all the LoD is a feature of BJS, running in the CPU.
It wouln’t be bad if the BJS tells, if it the cyclic load adds to the GPU or CPU to optimize the render time.

I found this example (ThreeJS) WebGL LOD implementation - Jérémy BOUNY

1 Like

This check is always on the CPU. It doesn’t matter if you have the customLODSelector or not.

I made an example:
https://playground.babylonjs.com/#3YYRD0#12 - version 12
It’s a bit complex but the use of the customLODSelector is easy to read, isn’t it?

1 Like