Skip to content

keep interpolated positions exact so mob shadows stop flickering - #852

Merged
Purdze merged 2 commits into
masterfrom
shadow-flicker
Oct 30, 2026
Merged

Purdze merged 2 commits into
masterfrom
shadow-flicker

Conversation

@Purdze

@Purdze Purdze commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor / code cleanup
  • Performance improvement
  • Chore / tooling
  • Documentation

Summary

shadows under moving mobs flickered. Position::lerp used glam's a * (1 - s) + b * s, which isn't exact when both ends match: an interpolation step at y = -60 gave -60.00000000000001, the shadow's floor dropped to the cell inside the block below, and the shadow vanished for that frame (about a third of frames while a mob moves on superflat). it now uses a + s * (b - a) like Mth.lerp, which covers interpolation steps and the per-frame render lerp.

Reference

Vec3.lerp, Mth.lerp, LinearInterpolationHandler.doInterpolate, EntityRenderer.extractShadow

Testing

unit test that a lerp between equal positions stays exact at -60 and -63; this is the reliable guard. new entities/shadow_interpolation nudges a pig by one wire step (1/4096 of a block) six times and matches ten frames of each interpolation against the still one, allowing 100 pixels for the nudge's edge flips (a lost shadow changes ~3700). whether a frame lands on the bad tick depends on tick timing the harness can't pin, so on master it failed 4 of 6 runs; with the fix it passes every run, and on the vanilla harness. adds max_differing_pixels to match_screenshots for that. full just ingame-test passes.

other position lerps (first-person camera pivot, particles, the dark-disc eye height) still use the inexact form; none feeds a block floor, so they're left for a separate change.

@github-actions github-actions Bot added the bug Something isn't working label Oct 30, 2026
@Purdze
Purdze merged commit bb67c78 into master Oct 30, 2026
16 checks passed
@Purdze
Purdze deleted the shadow-flicker branch October 30, 2026 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant