How to enable LOD scaling on MultiMeshInstance3D Instanced from GDScript and assigned 'plant.res' mesh from GDScript..

Godot Version

4.3.Stable

Question

I am currently making the foliage of an open world game. My basic strategy for this is that I have a specific plant object exported as .gltf and imported with the plant mesh saved locally to disk as ‘plant-mesh.res’.

Inside the main over-world scene, I have a Node3D with a bunch of MeshInstance3Ds as children. For each child MeshInstance3D, which I will call the placement mesh, I have a script that instances a MultiMeshInstance3D and adds one ‘plant-mesh.res’ instance on every vertex of the ‘placement mesh’.

So far so good. However, I’m having trouble determining if Godot’s automatic level of detail scaling is active for these MultiMeshes that are being created in GDScript. Since I’m simply attaching a ‘.res’ mesh to the multimesh instance, and the multimesh itself didn’t come about from any sort of imported scene, I suspect that no LOD meshes are being generated to replace the ‘.res’ mesh I’m giving to the MultiMesh Instance.

I haven’t been able to find information in the documentation about generating lod meshes from GDScript outside of importing a scene, and even then, I’m not sure that just generating the meshes is enough for Godot to automatically use them properly in each MultiMeshInstance.

Does anybody know how I can very if LOD scaling is working properly on these MultiMeshInstance3D nodes? And, if it’s not working by default, then how would I properly “enable” the LOD scaling?

Thank you very much for your time.

For those interested in the code:

func populate_children():
	var children = get_children()
	
	for child in children:
		var node: TreePlanter = TreePlanter.new()
		node.set_global_transform(child.get_global_transform())
		node.p_mesh = child.get_mesh()
		node.receive_mesh(instance)
		
		# Eventually we will load the collision mesh and pass it to the planter
		# node. However, we need to be careful, as we pass different collision
		# meshes depending on which t_mesh we are using, as well.
		node.collision = null
		add_child(node)
		child.visible = false
		node.rebuild()

Where TreePlanter is a node that extends the MultiMeshInstance3D node. ^^;

Thank you very much for your time.

You can use GeometryInstance3D.lod_bias to check. But I’m pretty sure that a MultiMeshInstance3D will be considered as one “model” so all its contents will change at once.

1 Like

Ah! Thank you, mrcdk! This is exactly what I was looking for!