KhronosGroup / glTF

glTF – Runtime 3D Asset Delivery
Other
7.02k stars 1.13k forks source link

Accessor zero-initialization: Allow default-initialization? #2362

Closed appgurueu closed 5 months ago

appgurueu commented 5 months ago

The specification states the following on accessor.bufferView:

The index of the buffer view. When undefined, the accessor MUST be initialized with zeros.

However, this requirement is not useful in the case that the accessor must not contain zeros.

For example in the cases of quaternions or inverse bind matrices, an all zero quaternion or all zero inverse bind matrix would be invalid. It is more useful to "default-initialize" quaternions to identity quaternions and inverse bind matrices to identity matrices.

Hence, a zero-initialized sparse accessor for these properties would not be feasible; it would have to override all of the elements.

Why not allow implementations to "default initialize" the accessor in these cases? (I am working on a C++ implementation which will naturally fill the accessor with identity quaternions / matrices.)

lexaknyazev commented 5 months ago

Why not allow implementations to "default initialize" the accessor in these cases?

Accessors are generally not aware of their usage. For example, a floating-point VEC4 accessor may be used for:

"Default initialize" would require deferring data initialization until the effective accessor usage is known and duplicating the accessor if it's used more than once and its usages imply different default values.

appgurueu commented 5 months ago

Thanks, good point.