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

Tangent space computation is under-specified #1367

Closed
Themaister opened this issue Jun 11, 2018 · 4 comments
Closed

Tangent space computation is under-specified #1367

Themaister opened this issue Jun 11, 2018 · 4 comments

Comments

@Themaister
Copy link

Reference: KhronosGroup/glTF-Sample-Models#174

When you have engine-computed normals, the spec says that the application should use the "default MikkTSpace algorithms", but I have run into issues where MikkTSpace and the reference code for generating tangents do not match in the W component.

The issue which needs to be clarified is:
What is the inferred bi-tangent sign when loading a model which does not have tangents? The reference PBR shaders seem to suggest that W is always 1 (i.e. B = cross(N, T)), but that disagrees with MikkTSpace output in many cases.

In general, I would like to see tangent-generating better specified when TANGENT accessors do not exist.

@Themaister Themaister changed the title Tangent space computation are under-specified Tangent space computation is under-specified Jun 11, 2018
@Ybalrid
Copy link
Contributor

Ybalrid commented Jun 18, 2019

Tehre's also the issue that even if you have normal, you may not have tangent and/or need to recompute the tangent vectors. This redirect you to Appendix A, that is still a TODO.

Should something about recalculating TANGENT vertex attribute, because there's an infinite number of tangents to a surface. All I know is that common practice is to align TANGENT and BITANGENT (BINORMAL) with the UV plane.

@emackey
Copy link
Member

emackey commented Jun 18, 2019

The glTF spec does specify the format of the normal maps though:

The normal vectors use OpenGL conventions where +X is right and +Y is up. +Z points toward the viewer.

I tried to spell out the implications of that in this comment: mrdoob/three.js#11438 (comment)

@Ybalrid
Copy link
Contributor

Ybalrid commented Jun 18, 2019

Thanks @emackey, I will read through that carefully when I'll have some time! 😄

@lexaknyazev
Copy link
Member

When tangents are missing, the engines should generate them using MikkTSpace algorithms based on the positions, normals, and texture coordinates present. Bitangent vectors are always computed as a cross product of normals and tangents multiplied by the tangent's W component.

Any issues with particular implementations should be reported to their repos.

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

No branches or pull requests

4 participants