Skip to content

Commit

Permalink
The sad truth, baited
Browse files Browse the repository at this point in the history
- Fix packed uvs from being saturated
  • Loading branch information
Jozufozu committed Oct 6, 2024
1 parent 3dac118 commit 39b2508
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ private void setUvs(BakedGlyphExtension glyphExtension) {
float v0 = glyphExtension.flywheel$v0();
float v1 = glyphExtension.flywheel$v1();

packedUs = ((int) DataPacker.packNormU16(u1) << 16) | (int) DataPacker.packNormU16(u0);
packedVs = ((int) DataPacker.packNormU16(v1) << 16) | (int) DataPacker.packNormU16(v0);
// Need to make sure at least u0/v0 don't get their sign bit extended in the cast.
// It causes u1/v1 to be completely saturated.
packedUs = (Short.toUnsignedInt(DataPacker.packNormU16(u1)) << 16) | Short.toUnsignedInt(DataPacker.packNormU16(u0));
packedVs = (Short.toUnsignedInt(DataPacker.packNormU16(v1)) << 16) | Short.toUnsignedInt(DataPacker.packNormU16(v0));
}
}

0 comments on commit 39b2508

Please sign in to comment.