KhronosGroup / glTF-Validator

Tool to validate glTF assets.
Apache License 2.0
372 stars 63 forks source link

Byte Alignment With 16-Bit Values #194

Closed mikedh closed 2 years ago

mikedh commented 2 years ago

I've been trying to get an exporter to pass the validator under all circumstances, and I noticed that exports with a custom uint16 and int16 vertex attribute fail the validator with the following:

Error Message Pointer
MESH_PRIMITIVE_ACCESSOR_UNALIGNED Vertex attribute data must be aligned to 4-byte boundaries. /meshes/0/primitives/0/attributes/_CustomUInt16Scalar
MESH_PRIMITIVE_ACCESSOR_UNALIGNED Vertex attribute data must be aligned to 4-byte boundaries. /meshes/0/primitives/0/attributes/_CustomInt16Scalar

The confusing part to me is that:

Here's a prettier formatted copy of the JSON header: https://gist.github.com/mikedh/82522310b1fc403efaa08c3dc4579203 Here's the zipped minimal GLB file: cust16.glb.zip

Thanks for the great project!

lexaknyazev commented 2 years ago

Each attribute value, not just the starting offset must be aligned to 4-byte boundaries. Scalar uint16 attribute values use only 2 bytes, so they need 2-byte padding (could be achieved via bufferView.byteStride) to conform.

mikedh commented 2 years ago

Ah that clarifies it, thanks!