From 39b2508d0259d3c18fb872c43b3e9f15c6aa1c4b Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Sat, 5 Oct 2024 21:21:21 -0700 Subject: [PATCH] The sad truth, baited - Fix packed uvs from being saturated --- .../engine_room/flywheel/lib/instance/GlyphInstance.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/src/lib/java/dev/engine_room/flywheel/lib/instance/GlyphInstance.java b/common/src/lib/java/dev/engine_room/flywheel/lib/instance/GlyphInstance.java index c5e999d9f..4278913a7 100644 --- a/common/src/lib/java/dev/engine_room/flywheel/lib/instance/GlyphInstance.java +++ b/common/src/lib/java/dev/engine_room/flywheel/lib/instance/GlyphInstance.java @@ -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)); } }