Skip to content

Fix tangent/bitagent encoding when computing vertex skinning#120901

Open
Gaktan wants to merge 1 commit into
godotengine:masterfrom
Gaktan:fix-skeleton-binormal-sign-encoding
Open

Fix tangent/bitagent encoding when computing vertex skinning#120901
Gaktan wants to merge 1 commit into
godotengine:masterfrom
Gaktan:fix-skeleton-binormal-sign-encoding

Conversation

@Gaktan

@Gaktan Gaktan commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

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 sign function 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

@Gaktan Gaktan requested a review from a team as a code owner July 3, 2026 16:36
@Nintorch Nintorch added this to the 4.x milestone Jul 3, 2026
@Gaktan Gaktan force-pushed the fix-skeleton-binormal-sign-encoding branch from 3bdc078 to a5ca958 Compare July 3, 2026 16:46
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.

2 participants