fix: round interpolated texture tile sizes#1121
Open
banteg wants to merge 1 commit into
Open
Conversation
roborich
added a commit
to roborich/libultraship
that referenced
this pull request
Jun 22, 2026
Cherry of banteg's open upstream PR (feat/fix-interpolated-tile-size). Fixes animated water/lava textures jittering at high FPS (interpolation on) — e.g. Lake Hylia water — where (high-low+4)/4 tile-size math truncated an interpolated 31.9999 to 31, so the import-clamp and draw-time texture window disagreed by a texel across sub-frames (alternating 32x32 / 32x31). Adds GetTileSizeFromCoordinates() (rounds via lroundf) and routes the 4 ImportTexture* clamps + the GfxSpTri1 draw-time size through it. Backend- agnostic (interpreter.cpp only), so it fixes D3D11/OpenGL/Metal alike. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
roborich
added a commit
to roborich/Shipwright
that referenced
this pull request
Jun 22, 2026
…ile sizes) Points the toon submodule at the LUS commit that cherry-picks Kenix3/libultraship#1121, fixing high-FPS water/lava texture jitter (Lake Hylia). See toon-lighting.md for the upstream-merge action item. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
roborich
added a commit
to roborich/libultraship
that referenced
this pull request
Jun 22, 2026
Cherry of banteg's open upstream PR (feat/fix-interpolated-tile-size). Fixes animated water/lava textures jittering at high FPS (interpolation on) — e.g. Lake Hylia water — where (high-low+4)/4 tile-size math truncated an interpolated 31.9999 to 31, so the import-clamp and draw-time texture window disagreed by a texel across sub-frames (alternating 32x32 / 32x31). Adds GetTileSizeFromCoordinates() (rounds via lroundf) and routes the 4 ImportTexture* clamps + the GfxSpTri1 draw-time size through it. Backend- agnostic (interpreter.cpp only), so it fixes D3D11/OpenGL/Metal alike.
roborich
added a commit
to roborich/Shipwright
that referenced
this pull request
Jun 22, 2026
…ile sizes) Points the toon submodule at the LUS commit that cherry-picks Kenix3/libultraship#1121, fixing high-FPS water/lava texture jitter (Lake Hylia). See toon-lighting.md for the upstream-merge action item.
roborich
added a commit
to roborich/Shipwright
that referenced
this pull request
Jun 22, 2026
…ile sizes) Points the toon submodule at the LUS commit that cherry-picks Kenix3/libultraship#1121, fixing high-FPS water/lava texture jitter (Lake Hylia). See toon-lighting.md for the upstream-merge action item.
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.
Summary
This fixes interpolated texture tile dimensions being truncated after
uls/ult/lrs/lrtinterpolation.The bug showed up on macOS/Apple Silicon as animated water/lava textures visibly jittering when interpolation is active. In the Fire Temple lava repro, one replay phase derived a different rendered texture window from the interpolated tile coordinates:
Adjacent phases for the same surface stayed
32x32, so the visible symptom was an alternating32x32/32x31texture window.Root Cause
Several paths in
src/fast/interpreter.cppderive rendered/imported tile dimensions with:Those results were then cast directly to integer types. With interpolated float coordinates, a texel count that is logically
32.0can land slightly below the integer boundary, so truncation turns it into31.That makes the texture clamp/import and draw-time texture size calculations disagree across interpolation phases, producing the observed water/lava animation jitter.
Fix
Add
GetTileSizeFromCoordinates()and use it for the tile-size calculations that derive dimensions from interpolated tile coordinates. It keeps non-positive sizes clamped to0and rounds the derived texel count withlroundf.Related Links
Validation
cmake -S . -B build -DLUS_BUILD_TESTS=OFFcmake --build build --target libultraship -j 8cmake -S . -B build -DLUS_BUILD_TESTS=ONcmake --build build --target lus_tests -j 8ctest --test-dir build --output-on-failure