Animated textures can de-sync with Animate Only Visible Textures enabled
Purrrpley opened this issue ยท 3 comments
Version information
mc1.19.2-0.4.4+build.18
Expected Behavior
When Animate Only Visible Textures is enabled, only visible textures should be animated, and when a texture becomes visible it should skip ahead to the frame it should be at.
Actual Behavior
It does not skip ahead, so animated textures get de-synced from each other. Normally this doesn't matter because most of the time the animated textures are independent of each other, but it is a difference to vanilla behaviour because they always stay synced in vanilla, and sometimes it does matter. For example, if you want to make redstone lamps animate in a rainbow, you'd need both their on and off textures to be kept in-sync with each other, otherwise this happens:
Reproduction Steps
- Have a resource pack where textures being de-synced is easy to notice (like my rainbow lamps one).
- Make sure Animate Only Visible Textures is disabled.
- Make a new empty world (super flat maybe) or something so there's no existing redstone lamps already visible.
- Place a couple redstone lamps, wait a bit (5 seconds maybe?), then power one of them.
- Notice that they're different colours (not just one being darker because it's off) when they wouldn't be if their animations were kept in sync with each other (can test that by enabling Animate Only Visible Textures and reloading resource packs to reset the frame counters).
Java version
Java 17
CPU
i7-10700F
GPU
RTX 3070
Additional information
This happens because when an animated texture gets marked as not visible it stops animating, and when it becomes visible again it continues to animate from where it left off instead of skipping forward to the frame it should be. Some moduloing of the world time (or whatever tick time animated textures use) when an animated texture becomes visible again might fix it... Something around this line I think:
https://github.com/CaffeineMC/sodium-fabric/blob/b15f95bd7f5bb0384c2ed638062b20680fc2e514/src/main/java/net/caffeinemc/sodium/mixin/features/texture_tracking/MixinSprite.java#L13
You're correct in your analysis, and the proposed solution (keeping track of a timer so that the animation gets restored to the right frame) would be acceptable to me.
I'll mark this issue as up for grabs, and whoever else can take it on.
This can't be fixed the same way in 1.19.3. A new fix will have to be proposed.
Interpolation exists now, and we also need to make sure that isn't put off track.