Moo-Ack-Productions / MCprep

Blender python addon to increase workflow for creating minecraft renders and animations
https://theduckcow.com/MCprep
GNU General Public License v3.0
278 stars 26 forks source link

Animate texture improvements #161

Open TheDuckCow opened 3 years ago

TheDuckCow commented 3 years ago

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

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": {}
}
TheDuckCow commented 2 months ago

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:

image

Something for us to consider.

TheDuckCow commented 2 months ago

Reference file from Aspirata who made an updated version for us to consider:

Texture_animator.blend.zip

Mathew324 commented 2 weeks ago

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 :>

TheDuckCow commented 2 weeks ago

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