Fix tangent/bitagent encoding when computing vertex skinning#120901
Open
Gaktan wants to merge 1 commit into
Open
Fix tangent/bitagent encoding when computing vertex skinning#120901Gaktan wants to merge 1 commit into
Gaktan wants to merge 1 commit into
Conversation
3bdc078 to
a5ca958
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem(s) does this PR solve?
Additional information
My previous PR #117401 had some caveats. For instance, it did not take the binormal sign encoding into account.
The way it works is that the binormal sign is encoded in Oct.y. Oct.y is encoded as UNORM16, so values > 0.5 means positive, and values < 0.5 means negative. Since UNORM16 encoding does not allow a value of exactly 0.5 (aka zero once unpacked), the binormal sign was flip-flopping between positive and negative.
The fix is to clamp the Oct.Y value between [1.0/65535.0; 1-(1.0/65535.0)]. This also avoids the issue with compression detection altogether (what PR #117401 tried to fix).
I also removed usage of some
signfunction as its not very efficient on the GPU because it handles many different cases (+/-INF and zero). It's a lot simpler to just check if >= 0