Old sprite is displayed for first frame where animated texture becomes visible
Sinsei33 opened this issue ยท 4 comments
Bug Description
Not quite sure if it is a bug, or i missed something.
I'm creating my own mod. One part is a specific animated block where i can rotate the animated texture (kinda like with water/lava).
To do this i created a custom renderer for that block and need to calculate the UV values myself as well as call the vertex method for the VertexConsumer.
I also learned that i needed to call SpriteUtil.markSpriteActive with embeddium, or else the texture isnt animated.
The problem is the following:
Whenever i place the block and no other instance of that block is placed, the frames of the animated texture seem to begin with the first frame (even though it should show another frame) and then jump to the correct frame order.
Basically kinda like this:
Expected order of frames:
5 6 7 8 9 ...
What i get:
1 6 7 8 9
Reproduction Steps
Place block with custom renderer and self called vertex in world as first instance of that block.
Log File
This is a side effect of texture animations not being run for textures that aren't visible. It can theoretically be fixed by tracking exactly when the texture first becomes visible more carefully, and immediately uploading the appropriate frame at that time, outside of the regular texture animation ticks.
I haven't bothered to do this so far because the discrepancy is quite hard to notice in practice (at least for me) and only occurs on the first frame where the texture becomes visible.
I also learned that i needed to call SpriteUtil.markSpriteActive with embeddium, or else the texture isnt animated.
I hook the getU0
method on TextureAtlasSprite
. As long as this is called by something (whether vanilla's own sprite UV logic, or your own) on each frame where you render the vertex data, the texture should animate without needing to manage Embeddium-specific compat.
Thanks will try that.
Yeah, it isnt that big of a deal, so i'm probably just gonna live with it.
And thanks for the great work on this mod <3