Skip to content

GLTF: Support MultiMesh objects using EXT_mesh_gpu_instancing#112866

Draft
aaronfranke wants to merge 2 commits intogodotengine:masterfrom
aaronfranke:gltf-multi-mesh-gpu-inst
Draft

GLTF: Support MultiMesh objects using EXT_mesh_gpu_instancing#112866
aaronfranke wants to merge 2 commits intogodotengine:masterfrom
aaronfranke:gltf-multi-mesh-gpu-inst

Conversation

@aaronfranke
Copy link
Copy Markdown
Member

@aaronfranke aaronfranke commented Nov 17, 2025

Fixes issue #109280, supersedes PR #107866.

Draft because this depends on PR #113202, PR #113206, PR #113245, and PR #113247.

This PR adds support for importing glTF EXT_mesh_gpu_instancing nodes as Godot MultiMesh nodes:

Screenshot 2025-11-16 at 1 30 54 PM

In master, this extension was not supported, which meant that such objects were not imported as multiple instances.

This PR also adds support for exporting MultiMesh nodes as glTF EXT_mesh_gpu_instancing, and configuring the export behavior. Users can choose to use the extension, use plain glTF nodes, or use both:

Screenshot 2025-11-16 at 12 42 04 PM

Note that the dropdown only appears when the scene contains at least one MultiMeshInstance3D node, so it won't clutter the export settings UI in most cases where the user does not have any such nodes in their scene.

The options have the following behavior:

  • Optional EXT_mesh_gpu_instancing: Convert MultiMesh nodes into the EXT_mesh_gpu_instancing extension. The extension is marked as not required, so implementations without support can still load the file, but they will see a single mesh instead of multiple instances of meshes.
  • Required EXT_mesh_gpu_instancing: Convert MultiMesh nodes into the EXT_mesh_gpu_instancing extension. The extension is marked as required, so implementations without support cannot load the file.
  • Multiple Nodes Only: Convert MultiMesh nodes into multiple glTF nodes. This is similar to the existing behavior in master, but there are multiple bugs with the current master, which have been fixed in this PR.
  • Multiple Nodes Fallback: Convert MultiMesh nodes into both the EXT_mesh_gpu_instancing extension and multiple nodes, allowing it to be imported as a MultiMesh when supported, or imported as nodes when not supported.

Here's what it looks like when loading a glTF exported with "Multiple Nodes Fallback" into Godot 4.5-stable:

Screenshot 2025-11-16 at 12 36 37 PM

This PR also makes several related changes:

  • Adjust SceneImportSettingsDialog::_fill_scene to handle MultiMeshInstance3D nodes.
  • Add a new function _export_configure_for_scene to GLTFDocumentExtension, allowing extensions to be configured before the export process starts, so that they can customize what properties are shown.
  • Unify Mesh to ImporterMesh conversion logic and move it to ImporterMesh::from_mesh.
  • Add a function to GLTFState to generate a unique name (previously was private to GLTFDocument).
  • Fix a bug where MultiMesh's own transform was multiplied into each instance.
  • Fix a bug where 2D MultiMesh transforms were swapping the Y coordinate into Z.
  • Fix a bug where the material name was used as the surface name instead of the surface name.
  • Fix an issue where extensions added export settings before the base glTF settings finished being added.
  • Fix an issue where buffers and accessors were not loaded by the time nodes were parsed. Nodes can depend on buffers and accessors, so the buffers and accessors need to be loaded first.
  • Fix an issue where buffers and accessors were serialized before nodes were serialized. Exported nodes can write data to buffers and accessors, so the buffers and accessors need to be serialized after.

@aaronfranke aaronfranke requested review from a team as code owners November 17, 2025 00:56
@aaronfranke aaronfranke added this to the 4.6 milestone Nov 17, 2025
@aaronfranke aaronfranke moved this to Ready for review in Asset Pipeline Issue Triage Nov 17, 2025
@aaronfranke aaronfranke force-pushed the gltf-multi-mesh-gpu-inst branch from 5efa1a8 to 0e790eb Compare November 17, 2025 02:18
@Repiteo Repiteo changed the title GLTF: Support MultiMesh objects using EXT_mesh_gpu_instancing GLTF: Support MultiMesh objects using EXT_mesh_gpu_instancing Nov 17, 2025
@fire
Copy link
Copy Markdown
Member

fire commented Nov 18, 2025

Adding multimesh support to godot engine gltf is a good idea. Need to pick a time to review. Other reviewers are welcome too.

@aaronfranke aaronfranke force-pushed the gltf-multi-mesh-gpu-inst branch from 082cc45 to 4287e0b Compare November 19, 2025 01:59
@Repiteo Repiteo modified the milestones: 4.6, 4.x Nov 19, 2025
@aaronfranke
Copy link
Copy Markdown
Member Author

aaronfranke commented Nov 27, 2025

I split this into PR #113202, PR #113206, PR #113245, and PR #113247. These can be merged first, and then I can rebase and undraft this PR.

@aaronfranke aaronfranke force-pushed the gltf-multi-mesh-gpu-inst branch from b6325a3 to 3e4a2e1 Compare December 6, 2025 07:26
@aaronfranke aaronfranke force-pushed the gltf-multi-mesh-gpu-inst branch 2 times, most recently from 553d2f4 to 3a96db6 Compare January 10, 2026 19:07
@fire
Copy link
Copy Markdown
Member

fire commented Jan 10, 2026

Seems to be blocked on #113247

@aaronfranke aaronfranke force-pushed the gltf-multi-mesh-gpu-inst branch from 3a96db6 to 8003d6e Compare February 26, 2026 03:12
@aaronfranke aaronfranke force-pushed the gltf-multi-mesh-gpu-inst branch from 8003d6e to 844d9b8 Compare March 5, 2026 07:37
@aaronfranke aaronfranke force-pushed the gltf-multi-mesh-gpu-inst branch from 844d9b8 to 1d213bc Compare March 30, 2026 10:27
@aaronfranke aaronfranke force-pushed the gltf-multi-mesh-gpu-inst branch from 1d213bc to ff90da3 Compare March 30, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Work in progress

Development

Successfully merging this pull request may close these issues.

4 participants