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

Zero-length tangents being generated #30

Open
LPGhatguy opened this issue Jul 7, 2023 · 2 comments
Open

Zero-length tangents being generated #30

LPGhatguy opened this issue Jul 7, 2023 · 2 comments

Comments

@LPGhatguy
Copy link

LPGhatguy commented Jul 7, 2023

We use the mikktspace crate to generate tangents when loading models in our engine. Recently, we introduced bloom and found out that we've had some very rare NaN outputs in our fragment shader. We traced back the issue and found out that the mikktspace crate generates zero-length tangents occasionally, causing them to turn into NaN when normalized.

This model from the glTF Sample Model repository exhibits this issue: https://github.com/KhronosGroup/glTF-Sample-Models/blob/4ca06672ce15d6a27bfb5cf14459bc52fd9044d1/2.0/DamagedHelmet/glTF-Binary/DamagedHelmet.glb

On face 2923, vertex 2, a tangent of (0.0, 0.0, 0.0, -1.0) is generated by this crate. The model appears to have nothing weird about it, and Blender generates correct tangents for all vertices if set during export.

@alteous
Copy link
Member

alteous commented Jul 12, 2023

This will require some investigation. It could be an issue with the original C algorithm that was patched later (in Blender or otherwise) or it could be been introduced inadvertently by us.

@LPGhatguy
Copy link
Author

We hit this issue again! This time, it looks like bad tangents are coming from Blender on a different model. It looks like they have a similar bug, it just didn't pop up on this model.

Here is a slice of a model I got from Sketchfab that generates zero-length tangents with both this crate and Blender: umprail.zip

It has pretty awful topology, but I don't think any program should ever generate invalid tangents in that case, right?

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