google / bigwheels

BigWheels is a cross-platform, API agnostic framework to build graphics applications.
Apache License 2.0
85 stars 34 forks source link

[glTF] Support bufferView stride (interleaved attributes) #472

Open footballhead opened 1 month ago

footballhead commented 1 month ago

The current implementation of GltfLoader::LoadMeshData assumes that each attribute is stored tightly packed. However, glTF allows for interleaved attributes, see 3.6.2. Trying to load interleaved data like it is tightly packed results in garbage output.

BigWheels should support interleaved attributes in order to correctly load models like:

footballhead commented 1 month ago

A curious case of this is SimpleTexture; the UVs are stored as four triples: (U_1, V_1, 0), (U_2, V_2, 0), (U_3, V_3, 0), (U_4, V_4, 0). If you stride the buffer then you only read the UVs and skip the 0. However, if you don't stride then you read (U_1, V_1), (0, U_2), (V_2, 0), (U_3, V_3)