GLTF: Support MultiMesh objects using EXT_mesh_gpu_instancing#112866
GLTF: Support MultiMesh objects using EXT_mesh_gpu_instancing#112866aaronfranke wants to merge 1 commit into
EXT_mesh_gpu_instancing#112866Conversation
5efa1a8 to
0e790eb
Compare
EXT_mesh_gpu_instancing
|
Adding multimesh support to godot engine gltf is a good idea. Need to pick a time to review. Other reviewers are welcome too. |
082cc45 to
4287e0b
Compare
4287e0b to
b6325a3
Compare
b6325a3 to
3e4a2e1
Compare
553d2f4 to
3a96db6
Compare
|
Seems to be blocked on #113247 |
3a96db6 to
8003d6e
Compare
8003d6e to
844d9b8
Compare
1d213bc to
ff90da3
Compare
ff90da3 to
874259f
Compare
874259f to
f2eb613
Compare
fire
left a comment
There was a problem hiding this comment.
Seems to be ready to go. Some good user testing too!
Does multimesh instancing in gltf support skinned meshes? How does this handle it?
|
@fire No, skinned meshes are out of the scope which MultiMesh and EXT_mesh_gpu_instancing are meant to cover. |
fire
left a comment
There was a problem hiding this comment.
I think this is a good idea. Requires QA. #112866 (comment) may be sufficient qa.
Did not test.
|
Tested against master from 15min ago. Still working well. |
|
Hmm, I wonder if it might make more sense to instead import a single mesh resource during import and have multiple MeshInstances that all reference that single mesh resource. I am not convinced that this will necessarily result in better performance. I don't think we support combining multiple MultiMeshInstance, so each of them would end up as an individual draw call. So depending on the scene this might end up resulting in a performance regression compared to using duplicates as we currently do. e.g.: I have a table asset, which has 4 identical legs and one tabletop. I want to render 200 tables. Without using any kind of instance import this would result in us rendering each of the table legs once and then the table top, each with 200 instances. So rendering my entire scene would happen with just 5 draw calls. However, if MultiMeshes are used instead (as implemented by this PR) we could now render a single table using one MeshInstance (top) and one MMI (the four legs). Since MMI can't automatically be combined rendering out entire scene would now take 201 draw calls. (200 * MMI + 1 mesh instance for the batched table tops). If we instead could use MeshInstances for the leg instances and have all of them reference the same Mesh object we should be able to automatrically combine them when rendering, so the entire scene could be rendered with just two draw calls (one for all the legs, the other for the top). |
I have instance counts that can reach tens of thousands (feathers, roof tiling, stone walls, etc). While the server can coalesce the meshes, the MeshInstance3D overhead from that is not negligible even when coalesced. There is a separate issue with the blender importer not reusing mesh instances (outside of geometry nodes) that should also be fixed at some point, but that seems like a separate issue. Regardless, the current geometry node behavior is very taxing on performance. |
f2eb613 to
3107eb7
Compare
|
@Ansraer This PR does not automatically combine anything into MultiMesh / MultiMeshInstance3D. It only generates MultiMeshInstance3D where |
mikest
left a comment
There was a problem hiding this comment.
I have done the following testing:
- Blender 4.5 & 5.1 imported files
- Imported GN nodes with instance counts >10,000
No issues discovered yet.

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_instancingnodes as Godot MultiMesh nodes: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: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:
EXT_mesh_gpu_instancingextension. 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.EXT_mesh_gpu_instancingextension. The extension is marked as required, so implementations without support cannot load the file.EXT_mesh_gpu_instancingextension 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:
This PR also makes several related changes:
Test files: ext_mesh_gpu_instancing.zip