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

Some GLB/GLTF models load with incorrect vertex data #320

Closed
capdj opened this issue Mar 6, 2022 · 3 comments
Closed

Some GLB/GLTF models load with incorrect vertex data #320

capdj opened this issue Mar 6, 2022 · 3 comments

Comments

@capdj
Copy link

capdj commented Mar 6, 2022

Description

When loading some GLB files (that I've output via the SharpGLTF library), they seem to load with nonsense/out of range vertex positions.

Platform / Environment

Windows, both latest stable StereoKit and latest unstable packages from nuget

Logs or exception details

See this GLB file as an example:

https://1drv.ms/u/s!Ajjrnsetf5EDjPg3tBGSd2ZSs29LKg?e=INUgvM

I've cut this down to a reasonably small example file that exhibits the behaviour ... only two nodes, two meshes, about ~1K tris.

When loaded as a stereokit Model, it reports the bounds as:

{[center:[169234600000000000000000000000000000000.00, -169642900000000000000000000000000000000.00, 168716100000000000000000000000000000000.00] dimensions:[338469300000000000000000000000000000000.00, 339285800000000000000000000000000000000.00, 338469300000000000000000000000000000000.00]]}

Unsurprisingly with such huge coordinates it doesn't render on screen either!

The same GLB loads into Windows 3D Viewer and Blender (and the OneDrive automatic preview, I've just noticed!) and displays as expected ... the vertex coordinates should be roughly in a range of +-2000 around the origin, which looks to be what I'm seeing in Blender.

Nothing in the textual/GLTF version of the file looks particularly stupid, and it passes through the GLTF validator without issue so I'm assuming (maybe incorrectly!) that since it loads into a few other programs fine, the problem isn't on the SharpGLTF export side but is somewhere within StereoKit.

Let me know if I can provide any extra information to help track this down!

@maluoi
Copy link
Collaborator

maluoi commented Mar 7, 2022

Hey, thanks for the report, and thanks especially for the test model!

After a quick peek, I think this is the first interlaced vertex buffer I've seen in a GLTF, and StereoKit doesn't seem to handle it well! Fortunately, that seems like it'll be pretty easy to fix.

I'll get that fixed this week for sure! I am in the middle of some code for async texture loading, so I may not have a new build up until after that code is done. If ends up taking longer than a week, I'll try and get a build with just this fix in it. In the meantime, Blender's exporter works very well with StereoKit, you should be fine to just load and re-export from Blender :)

@capdj
Copy link
Author

capdj commented Mar 7, 2022

Ah - hadn't considered that as a possible problem, but it turns out SharpGltf has an option to disable interleaving buffers and that does get my models loading with sane vertex data, so no rush on the update. Thanks! Looks like some of my models are rendering with a bad winding order on the triangles, but that looks like it's probably a different problem (and potentially on my end when I'm constructing the model in SharpGltf) so I'll raise a separate issue if I can come up with a test case for that.

@maluoi
Copy link
Collaborator

maluoi commented Mar 28, 2022

This is available in v0.3.6-preview.4!

@maluoi maluoi closed this as completed Mar 28, 2022
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