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

Sanitize tangents when creating mesh surfaces to avoid triggering the compressed mesh path in the shader #83179

Merged
merged 1 commit into from Oct 13, 2023

Conversation

clayjohn
Copy link
Member

Fixes: #83175

This was a fun one to track down.

In the shader we check if (tangent.x > 0 || tangent.y < 1.0), to see if we should run the uncompressed path. I wrongly assumed that we would never send (0, 1) to the shader because (0, 1) maps to a tangent of (0, 0, -1, 1), but a tangent of (0, 0, -1, 1) maps to (1, 1). However, (-1e8, 0, -1, 1) maps to (0, 1) and sometimes we create tangents that are (-1e8, 0, -1, 1). We can't represent (-1e8, 0, -1, 1) in octahedral tangents anyway, so its fine to just force all cases of (0, 1) to (1, 1)

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks pretty hacky, but I trust that it's the correct solution :)

@akien-mga akien-mga merged commit 135fa1e into godotengine:master Oct 13, 2023
15 checks passed
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

TorusMesh exhibits a visible line due to incorrect mesh normals
2 participants