spnda / fastgltf

A modern C++17 glTF 2.0 library focused on speed, correctness, and usability

Home Page:https://fastgltf.readthedocs.io/v0.7.x/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lack of extensions or so...

tigrazone opened this issue · comments

Hello!
Thank you for fastgltf. It's impressive but not open all files from https://github.com/gkjohnson/3d-demo-data.git which use and can open https://github.com/gkjohnson/three-gpu-pathtracer.git
For example, I try to open https://raw.githubusercontent.com/gkjohnson/3d-demo-data/main/models/pathtracing-bathroom/modernbathroom.glb and fastgltf_gl_viewer fails with error

Loading c:\msys64\home\user\from-git\3d-demo-data\models\pathtracing-bathroom\modernbathroom.glb
Failed to load glTF: One or more extensions are required by the glTF but not enabled in the Parser.
Failed to parse glTF.

I find here is extension list and extend it to all possible

fastgltf::Parser parser(fastgltf::Extensions::KHR_mesh_quantization);

with change to
fastgltf::Parser parser((fastgltf::Extensions)~0);

After change fastgltf_gl_viewer fails with error

Loading c:\msys64\home\user\from-git\3d-demo-data\models\pathtracing-bathroom\modernbathroom.glb
Failed to load glTF: The glTF is either missing something or has invalid data.
Failed to parse glTF

Can you fix this error?

commented

Hi, thanks for the report.
First of all, the gl_viewer example simply does not support the EXT_meshopt_compression. I want to keep the example at a bare minimum and only support the core glTF specification. While some extensions are widely used, I will not add code to support them to the example. KHR_mesh_quantization was the only one I added because it required no additional code.

As for the parsing error you experienced after enabling the extensions in the parser, it turns out there was a part of the spec for EXT_meshopt_compression that I seem to have missed. It adds the concept of so-called fallback buffers which are buffers with a byteLength property but they contain no data. The code currently throws an error in this case because it expects to either have a uri property or use the GLB buffer, which is why you're getting that error.

I've now changed the code in an upcoming commit that adds a new (empty) data source called ´Fallback` that is used whenever the library detects the extension is enabled (and required by the asset) and a buffer has no data. It is then the users responsibility to always use the compressed buffer version.