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

support byteStride for glTF files #214

Open
russaa opened this issue Jan 15, 2025 · 1 comment
Open

support byteStride for glTF files #214

russaa opened this issue Jan 15, 2025 · 1 comment

Comments

@russaa
Copy link

russaa commented Jan 15, 2025

currently reading glTF data that utilizes byteStride in its accessors is not supported

(for example, the avatars at Ready Player Me use byteStride, see https://models.readyplayer.me/678703d63cb298e56bf50122.glb?morphTargets=ARKit&textureAtlas=1024)

I think this would need some refactoring of the gltf-loader gltf2.py:
currently, the Accessor and BufferView are intermixed in some places which prevents a easy implementation for reading buffer-data with defined byteStride.
See for example VBOInfo, or more precisely the creation of it from GLTFAccessor.info() which tries to merge data from GLTFAccessor and GLTFBufferView, and then implements its own read() method for reading & preparing the gl buffer, see implementation of GLTFMesh.load().
I think, the reason for this was, to be able to merge multiple accessors & buffer-views, to make the rendering more efficient. But the current implementation cannot i.m.o. easily changed to also support byteStride, since an efficient implementation would require information from the accessor & buffer-view.

I think it would be more clean, to implement & use an appropriate method in GLTFAccessor that supports byteStride.

As an example for how to read data with byteStride, see e.g. trimesh's implementation

I did try out the trimesh implementation and got it to work with gltf2.py, but as I mentioned, without some refactoring, the code is quite hacky.

@einarf
Copy link
Member

einarf commented Jan 16, 2025

Thanks for pointing out this flaw. It's definitely a bit hacky and needs improvements. It was really something I threw together over the weekend with the goal of supporting most of the files in the glTF sample repository.

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