Is there a way to access lod level of MeshInstance3D?

Godot Version

4.3 stable

Question

I need to make a lod based timer for manually ticking a lot of npcs, but I couldn’t find a way to access lod level of mesh. Is it possible? I am using automatic lods.

Without knowing more about the deep down rendering pipeline, while this will not too exact, you might be able to calculate it based on the way LOD transition distances are computed:

When rendering the scene, mesh LOD selection uses a screen-space metric. This means it automatically takes camera field of view and viewport resolution into account. Higher camera FOV and lower viewport resolutions will make LOD selection more aggressive; the engine will display heavily decimated models earlier when the camera moves away.

Not sure their exact equation, but with it being screen space you can try and get VisualInstance3D and get_aabb ( ) to try and compute the LOD value based on that and the mesh and instance settings. lod_bias on the mesh instance can help dial this in.

1 Like