Skip to content

fix: glTF parser - respect byteStride for all vertex attributes - #80

Open
transmutrix wants to merge 1 commit into
HailToDodongo:mainfrom
transmutrix:fix-parser-stride
Open

fix: glTF parser - respect byteStride for all vertex attributes#80
transmutrix wants to merge 1 commit into
HailToDodongo:mainfrom
transmutrix:fix-parser-stride

Conversation

@transmutrix

Copy link
Copy Markdown

Hi! Hopefully submitting a PR is ok. ^_^

What?

Makes the glTF parser compatible with .glb files that use interleaved vertex attributes by respecting bufferView.byteStride in all vertex attribute reads. The Blender exports I examined all show a byteStride of zero for all their bufferViews, so they parse exactly the same with these changes.

Why?

I am just getting started with N64 development and have been working through the Tiny3D examples and writing small tests of my own based on them. I haven't been able to get Fast64 working in Blender yet, but I wanted to try loading an original model.

So, I made a small model with some vertex colors and no textures using Wings 3D and exported it as a .glb file. I was able to get it to load, but the triangles were really messed up.

I first tried importing my .glb file in another program to make sure it wasn't just malformed, and it seemed fine. I then compared with existing .glb files in the examples and noticed the example .glb files don't specify byteStride for any of their bufferViews but my file does.

I changed the parser to respect the byteStride when one is set, and my model geometry now loads correctly.

Minimal Repro

This zip contains a minimal repro. Drop it in tiny3d/ and run the makefile to build it. With the unfixed parser, the model appears as a mess of triangles because the vertex attributes are read incorrectly (the "before" screenshot). With the fixed version, it should look like the "after" screenshot.

repro.zip

Before

Screenshot 2026-08-22 at 10 51 27 PM

After

Screenshot 2026-08-22 at 11 11 38 PM

Feedback

Please let me know if there are any changes I should make to be in keeping with the "house style" or something.

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

Successfully merging this pull request may close these issues.

1 participant