Animate texture improvements
Animate textures is great, but not perfect just yet. At the moment, any resource pack image that is detected to be animated is split into tiles and loaded as a 1:1 image sequence. This does not accurately reflect the ticks between tiles used in game, or the way that the game blends between these frames.
The goal is for MCprep to directly read the mcmeta file (e.g. campfire_log_lit.png.mcmeta), and implement the same sequencing as the game. This will require more advance processing of files, and potentially require some multi threading to make it not too glacially slow (especially for larger resolution packs). The set of features and funcitonalities:
Implementation
- Add support for
frametime, where frames are updated only every according number of ticks. This should try to map back to the game by considering also Blender's current frame rate. Minecraft has 20 game ticks per second, so will need to upscale e.g. to 24 or 30fps accordingly. The result will be a number of repeated frames saved to disk. Consider saving frames out to cache folders named based on the blender frame rate, so that there aren't clashes between projects. - Add support for
interpolate, where a given subframe blends between two explicit tiles. - Add support for
frames, where the mcmeta file explicitly references the order of the frames to use. From what I can see, typically used for "flipper" animations, where if there are 4 tiles, frames will = 0,1,2,3,2,1 - Detect size of the texture pack, in order detect things like lava still and flowing which actually have two columns of tiles, and so right now is being read incorrectly. It is not immediately obvious to me where I can detect this, shy of taking a known typically square, non animated texture and using that as a basis. We could also make a dumb hardcoded rule and just assume water/lava is two column, but this won't necessarily be true for all texturepacks.
References
Details about this file format here: https://minecraft.gamepedia.com/Resource_pack#Animation
As per the resource page above, there are some defaults that will apply to all where keys are not specified. These include frametime= 1, and interpolate=False. See full examples below, all are in json format
campfire_log_lit.png.mcmeta:
{
"animation": {
"interpolate": true,
"frametime": 20
}
}
lava_still.png.mcmeta:
{
"animation": {
"frametime": 2,
"frames": [
0,
1,
2,
...
18,
19,
18,
...
3,
2,
1
]
}
}
nether_portal.png.mcmeta:
{
"animation": {}
}
Another idea: we could revert all the python work (aside from reading frame dimentions), and go for a shader solution.
See the post here, where Aspirata created this node group, which even includes logic to allow for fading:
Something for us to consider.
Reference file from Aspirata who made an updated version for us to consider:
A hacky work a round for the texture speed is by using drivers.
In the Diffuse texture node set frames to 1 and set start frames to 0, then for offset use #frame/18 as shown in the video.
If you want it to cycle you can replace the #frame/18 with (frame/18)%20.
20 = Total frames
18 = Speed (blender frames till next texture frame if that makes sence)
Video example: https://github.com/user-attachments/assets/4d9eaf88-223d-4d55-a4e5-d10a462edfa8 Hope this helps anyone :>
Thanks for providing the suggestion! I might end up pointing people to that in the meantime as the dev work for the above is still somewhat in the backlog, thanks for sharing @Mathew324