-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add tangent vectors to 2 models per recent tangent basis clarifications #135
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is certainly fixed here but with two concerns.
- All meshes now have tangents, including those that do not use them. This leads to a lot of new warnings.
- How did the engines treat the affected models before this PR? Were they consistent and/or correct?
For (1), generally model authors don't have a lot of control over which exported meshes get tangents vs. not. For example, in both Blender and gltf-transform, the generation of tangents is an all-or-nothing single switch. Perhaps various exporters and pipeline tools could be made to automatically determine the need for tangents per-mesh based on the clarified rules going into the spec here, but that tooling does not currently exist, and the exact rules were not previously known. Something similar is happening with For (2), I've only investigated one software package so far, software that I work on internally. It calculates only a single TBN per fragment, using the Did adding tangent vectors fix it? Well it made it less ambiguous that the software should load the I certainly won't claim that the shader code I described earlier is desirable or representative of how other software packages work. We will have to investigate the source code for each package that we're curious about. |
This PR technically fixes the missing tangent space issue so it's an improvement in any case.
@donmccurdy What UV set is used for generating tangents when there is no normal texture on the base material? |
The current behavior is to use the normal map's UVs if present, or The operation doesn't look at any other textures, but those would be easy enough to add. I suppose it should look for texcoord overrides in |
The intention, as clarified in KhronosGroup/glTF#2409 and KhronosGroup/glTF#2415, is to ensure the following.
That said, it would be great if glTF-Transform could "fix" meshes that do not follow these rules. |
Hey @donmccurdy, hope things are going well for you!
Yes, this is the conclusion we came to in PBR TSG recently: The The tool could also discard unused tangents to save some validator warnings. But one caveat is that anisotropy itself can make use of tangents even without any texturemap being present, because anisotropy stretches roughness along tangents regardless of whether or you've textured it. So, tangents are needed by any mesh that has |
If texture transforms are animated, that would not work. I think we agreed to split this issue and investigate whether a runtime TBN transformation based on texture transform is possible. |
True. I guess we should investigate what shader changes are needed to incorporate texture rotation into tangent vectors at runtime. My hunch is that it should be just a rotation about the geometric normal, but I haven't done the math in full. |
Approved after discussion in Tooling TSG. Ed/Alexey to create issue against repo for remaining issues/points. |
Fixes #133, I believe.
Accomplished using Don's gltf-transform/cli with the
tangents
command.