Add Assimp GLTF/GLB/VRM support back in - #830
Conversation
adriengivry
left a comment
There was a problem hiding this comment.
LGTM! I'm just wondering how embedded materials metallic, roughness, albedo, emissive etc is being interpreted when a model is (for instance) authored in Blender, exported as GLTF, and imported in Overload. I know that different formats store this information differently, and Assimp isn't always the best at resolving those values. (see https://github.com/Overload-Technologies/Overload/blob/main/Sources/OvRendering/src/OvRendering/Resources/Parsers/AssimpParser.cpp).
Approved conditionally that these behaviors work as expected.
| @@ -77,7 +86,7 @@ project 'assimp' | |||
| 'ASSIMP_BUILD_NO_CSM_IMPORTER', | |||
| 'ASSIMP_BUILD_NO_DXF_IMPORTER', | |||
| -- 'ASSIMP_BUILD_NO_FBX_IMPORTER', | |||
| 'ASSIMP_BUILD_NO_GLTF_IMPORTER', | |||
| -- 'ASSIMP_BUILD_NO_GLTF_IMPORTER', | |||
There was a problem hiding this comment.
Commenting out ASSIMP_BUILD_NO_GLTF_IMPORTER enables both glTF 1.0 and glTF 2.0, since the importers are guarded by !ASSIMP_BUILD_NO_GLTF_IMPORTER && !ASSIMP_BUILD_NO_GLTF{1,2}_IMPORTER. glTF 1.0 has been superseded since 2017 and nothing exports it anymore, so this pulls in ~5k lines of vendored code (code/AssetLib/glTF/**) and an extra compiled importer for a format we don't need
It also costs us on every glTF import: glTFImporter::CanRead ignores the extension and fully loads and JSON-parses the file before returning false, and glTF1 is registered before glTF2 in ImporterRegistry.cpp
Could we add ASSIMP_BUILD_NO_GLTF1_IMPORTER to the defines and drop code/AssetLib/glTF/** from both the files block and the vendored tree ? glTF2 has no dependency on glTF1, and the only reference is ImporterRegistry.cpp:188, which is already behind that guard
| @@ -1506,7 +1506,7 @@ bool OvEditor::Core::EditorActions::ImportAsset(const std::string& p_initialDest | |||
| { | |||
| using namespace OvWindowing::Dialogs; | |||
|
|
|||
| std::string modelFormats = "*.fbx;*.obj;"; | |||
| std::string modelFormats = "*.fbx;*.obj;*.glb;*.gltf;*.vrm;"; | |||
There was a problem hiding this comment.
Since .gltf is now advertised here : a non-binary .gltf references an external .bin (and often external images), but ImportAsset / ImportAssetAtLocation copy a single file (L1544 and L1618). After importing one through this dialog, ReadFile fails on the missing buffer, LoadModel returns false and ModelLoader::Create returns nullptr with no log, so the asset shows up in the Asset Browser and silently never loads
.glb and .vrm are self-contained and unaffected. Worth copying the files referenced by the .gltf, or at least logging the load failure so the user knows what happened ?
There was a problem hiding this comment.
How are we handling that with FBX/OBJ? They can also reference external files
There was a problem hiding this comment.
We don't, it's the same single-file copy for all three
The difference is what breaks. For OBJ/FBX the external references are materials and textures, so a missing .mtl just logs an error and the parser carries on (ObjFileParser::getMaterialLib), you still get the mesh. For a text .gltf the .bin holds the geometry itself, so Buffer::Read throws (glTF2Asset.inl:619) and the whole import fails
What bothers me more is that nothing surfaces it : LoadModel returns false, ModelLoader::Create returns nullptr, and the asset just sits in the browser doing nothing. Maybe logging Importer::GetErrorString() there would be enough ? Would help FBX/OBJ too.
There was a problem hiding this comment.
oops, never thought about that. Maybe we should ask the user to select the dot bin file or deny adding gltfs using this way completely?
Gopmyc
left a comment
There was a problem hiding this comment.
Built it in Visual Studio on Windows 11, works fine. Integration looks clean overall.
Left two comments inline. One extra thing : glTF packs metallic and roughness into a single texture, but Standard.ovfx samples .r from both maps, while glTF stores roughness in G and metallic in B. Anything with a metallicRoughness map will come out wrong. Worth fixing here, or follow-up ?
|
@Gopmyc worth fixing IMO |
|
okay, should we edit the shader or convert the texture? I think converting might be the better way |
If the texture is embedded, and not user-driven (not available through the project files), then we can do whatever we want with it, including converting it. I agree that converting is better than modifying the shaders. |
|
i'm not sure if this fixes it, do you have a test model? |
Description
This PR adds GLTF/GLB/VRM support back into the engine
The VRM format is a gimmic by Assimp and works without that much extra code, so why not
Related Issue(s)
None
Review Guidance
Only tested on Debian Trixie
Screenshots/GIFs
AI Usage Disclosure
RAPIDJSON_HAS_STDSTRING told me chatgpt, otherwise no AI usage
Checklist