Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpretation of bytestride parameters #34

Closed
anthonysteed opened this issue Jun 16, 2017 · 5 comments
Closed

Interpretation of bytestride parameters #34

anthonysteed opened this issue Jun 16, 2017 · 5 comments

Comments

@anthonysteed
Copy link

I believe there may be a mistake in how bytestride is interpreted inside Accessors. The reference:

https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#floating-point-data

implies (it doesn't appear to be explicit) that the bytestride is the total stride between values, not the unused bytes.

In Accesor.cs:

https://github.com/AltspaceVR/UnityGLTF/blob/master/Assets/GLTF/Scripts/Schema/Accessor.cs

It appears that if ByteStride is set, then it is added onto a calculation of the component width. (E.G. line 312).

Most densely packed objects don't set byteStride, but collada2gltf does, see attached object. In this case the bytestride is only indicating that the data is tightly packed.

test2.zip

Anthony

@stevenvergenz
Copy link
Contributor

I think you're just looking at the wrong part of the spec. From the byte stride definition:

The stride, in bytes, between vertex attributes. When this is not defined, data is tightly packed. When two or more accessors use the same bufferView, this field must be defined. Minimum value: 4.

"Between" attributes suggests to me that it does not include the size of the component, implying that a byteStride of 0 would also indicate densely-packed data, but the spec authors prefer to omit the value entirely in this case.

The current algorithm has worked on all the sample models we've tried, but I admit it's possible that we misinterpreted. I don't think any of them use interleaved attributes or anything with byteStride. I'll ask the spec group.

@anthonysteed
Copy link
Author

I just think it is ambiguous, if you read this statement:

Each accessor must fit its bufferView, i.e., accessor.byteOffset + STRIDE * (accessor.count - 1) + >SIZE_OF_ELEMENT must be less than or equal to bufferView.length.

Then it implies the stride is the total stride, not the padding.

@anthonysteed
Copy link
Author

Wrong button.

This statement implies that the stride is the total stride, not the padding

Each accessor must fit its bufferView, i.e., accessor.byteOffset + STRIDE * (accessor.count - 1) +
SIZE_OF_ELEMENT must be less than or equal to bufferView.length.

@stevenvergenz
Copy link
Contributor

Well, it looks like you're right, though it took some digging. The byteStride definition references WebGL's vertexAttribPointer's stride parameter, which reads:

A GLsizei specifying the offset in bytes between the beginning of consecutive vertex attributes. Cannot be larger than 255.

That's unambiguous. I'll get this fixed soon.

@stevenvergenz
Copy link
Contributor

Fixed in 019b1c6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants