spnda / fastgltf

A modern C++17 glTF 2.0 library focused on speed, correctness, and usability
https://fastgltf.readthedocs.io/v0.8.x/
MIT License
301 stars 44 forks source link

gl_viewer skips primitive morph targets #37

Closed droettger closed 8 months ago

droettger commented 11 months ago

Follow-up to https://github.com/spnda/fastgltf/issues/36

Using continue when the accessor has no buffer view index for TEXCOORD_0 is incorrect. https://github.com/spnda/fastgltf/blob/main/examples/gl_viewer/gl_viewer.cpp#L423 The continue only works for the position attribute because that is strictly required.

For all other attributes that needs to be a runtime check, like in this case if (texCoordAccessor.bufferViewIndex.has_value()) to just skip the VAO 1 setting. The per mesh glVertexArrayElementBuffer at the end must still be done unconditionally or OpenGL will complain about an invalid input data types.

spnda commented 11 months ago

The check is whether the UV accessor has a buffer view associated with it. The example doesn't support sparse accessors at all currently. but I guess I could fix that fairly quickly by refactoring the code to use fastgltf::copyFromAccessor into some GL buffer. However, I wanted to keep the example fairly simple, so currently it just doesn't support sparse accessors and I honestly don't feel like completely refactoring how the example works for adding sparse accessor support. I'll leave this open as a reminder though.

spnda commented 8 months ago

This was fixed recently with https://github.com/spnda/fastgltf/commit/73673cc48803c53a103a6c1ca2bd45ff6c9b56da.