Instances of procedural generated meshes? Different UV or Material per Instance?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Codex of Dreams
:warning: Old Version Published before Godot 3 was released.

Hi,
I have some questions about mesh instances (is it the same as “Multimesh”?)

  1. Can one (at runtime) generate instances of (at runtime) procedural generated meshes?

  2. Will instances be treatet as one big mesh/object or as individual objects/meshes. So: is it possible to use LOD and cull distance etc. with them?

  3. Are different materials or different UV-parameters (e.g. for using a texture-atlas) per instance possible?

  4. Does it matter for any of this if SurfaceTool or ImmediateGeometry is used?

Greetings and thx, CoD

:bust_in_silhouette: Reply From: Zylann
  1. Multimesh is not the same as MeshInstance. The former refers to usage of hardware-instancing, which is the ability to draw many times the same mesh at low cost in a single draw call.

  2. Yes, you can do this with ImmediateGeometry, SurfaceTool, or generating the vertex and index arrays directly

  3. It’s you to decide. Generating one mesh will make… one mesh. You can use the same mesh on multiple MeshInstances, or have a unique mesh for all instances.

  4. You can have different materials per MeshInstance with the material_override property, which will override any eventual material found in the mesh used by the instance. So you can re-use the same mesh on multiple instances and still be able to have different materials (only supports one override though).

  5. Using SurfaceTool, ImmediateGeometry or Mesh API is up to you. ImmediateGeometry is good for geometry that changes every frame. SurfaceTool is good for generating an actual mesh that won’t change later on. Using the Mesh API directly is good if it’s easier for you to generate vertex arrays, normals and indices manually.