Skip to content

Commit 1919881

Browse files
committed
Documented the animation optimization feature.
1 parent d982a50 commit 1919881

10 files changed

+342
-1
lines changed

animation-optimization-visualization.ipynb

Lines changed: 283 additions & 0 deletions
Large diffs are not rendered by default.

docs/animations/creating_animations_from_scratch.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
(creating-animations-from-scratch)=
12
# Creating animations from scratch
23

34
In this section, you will learn how to create animations in Mcblend from scratch. It is assumed that the reader already knows how to make and export models in Mcblend. We will start with a simple model that has a single bone and a single cube connected to it.

docs/animations/essential_concepts.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The editor on the left side of the screen is the `Nonlinear Animation` editor. T
1414

1515
During the export process, the exported data for animations is not solely based on the NLA tracks. Mcblend exports the same animation that is visible in the 3D viewport during the preview, which can be affected by various factors such as constraints, inverse kinematics, and physics. This means that some bones in the model may not be animated in the NLA tracks, but they will be animated in the exported animation due to the influence of other factors that affect their movement. The keyframe times for the animations are based on the keyframe times in the NLA tracks, but not at the bone level. Essentially, if there is any keyframe at a certain time, Mcblend compares the pose of the entire model at that time to the pose of the model at the previous keyframe. If the pose is different for a given bone, Mcblend will add a keyframe for that bone to the exported animation. Any pose changes that occur between keyframes are not checked, which can lead to unexpected results, particularly when using physics, which often generates complex movement that requires many keyframes to be animated correctly.
1616

17+
(stepped-linear-smooth-animations)=
1718
## Stepped, Linear, and Smooth Interpolation
1819

1920
Minecraft supports three types of frames: stepped, linear, and smooth. Blender offers corresponding interpolation modes: constant, linear, and Bézier.

docs/animations/exporting_animations.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
(exporting-animations)=
12
# Exporting Animations
23

34
This section explains how to export animations from Mcblend and mentions some additional settings that can be configured before exporting.
@@ -8,4 +9,6 @@ Before exporting the animation, you can configure some additional settings in th
89

910
The `Override previous animation`, `Loop`, and `Anim Time update` settings are properties of Minecraft animations and are directly exported to the file. They have no effect on Mcblend. The `Frame start` and `Frame end` settings determine the range of frames that will be exported to the animation.
1011

11-
Exporting the animation is similar to exporting a model, as explained in the ["Creating animations from scratch"](/animations/creating_animations_from_scratch) documentation page. Simply go to `File > Export > Export Bedrock Animation` and select the export path.
12+
The `Optimize Animation` checkbox allows you to apply **lossy** optimization to the animation during export. This option also lets you configure the error acceptable margin for the optimization. More details in {ref}`Optimizing animations<optimizing-animations>` section.
13+
14+
Exporting the animation is similar to exporting a model, as explained in the {ref}`Creating animations from scratch<creating-animations-from-scratch>` documentation page. Simply go to `File > Export > Export Bedrock Animation` and select the export path.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
(optimizing-animations)=
2+
# Optimizing Animations
3+
When making animations with Mcblend, you often end up baking some parts of the animation especially when transformations in the animations are driven by something else (physics simulation, inverse kinematics etc.). Minecraft animation storage format is not designed to reduce the size so the animations that use a lot of keyframes often end up being very large.
4+
5+
To counteract this, Mcblend provides an option to optimize the animation during export.
6+
7+
**TL;DR:** In order to optimize the animation, you need to select the `Optimize Animation` checkbox in the `Object Properties` panel under the `Mcblend: Animations` tab and set the `Error margin` to a value that is appropriate for your animation. Bigger values will result in smaller files but will also result in less accurate animations. Smaller values will result in larger files but will also result in more accurate animations.
8+
9+
```{warning}
10+
The animation optimization works **only for the linear keyframes**. You can read more about the interpolation modes in the {ref}`Stepped, Linear, and Smooth Interpolation<stepped-linear-smooth-animations>` section.
11+
```
12+
13+
## How does it work?
14+
15+
The optimization algorithm used by Mcblend is really simple. Mcblend loops through all keyframes and checks if interpolating between the previous and next keyframe is close enough to the current keyframe. If it is, the current keyframe is removed.
16+
17+
![](/img/animations/animation-optimization-how-it-works.svg)
18+
19+
The `Error margin` is defined as the ratio between the distance moved from current keyframe and its interpolated alternative (`a`) to the distance moved from the previous keyframe to the next keyframe (`b`). In the picture you can see that as `error=a/b`.
20+
21+
### Examples
22+
Examples below show how different levels of optimization affect the graph of the animation.
23+
24+
![](/img/animations/animation-optimization-example-raw.svg)
25+
![](/img/animations/animation-optimization-example-4pct.svg)
26+
![](/img/animations/animation-optimization-example-10pct.svg)
27+
28+

docs/img/animations/animation-optimization-example-10pct.svg

Lines changed: 6 additions & 0 deletions
Loading

docs/img/animations/animation-optimization-example-4pct.svg

Lines changed: 6 additions & 0 deletions
Loading

docs/img/animations/animation-optimization-example-raw.svg

Lines changed: 6 additions & 0 deletions
Loading

docs/img/animations/animation-optimization-how-it-works.svg

Lines changed: 6 additions & 0 deletions
Loading

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Fix invalid UV mapping<texturing_and_uv_mapping/fixing_invalid_uv_mapping>
3939
Essential concepts for creating animations in Mcblend <animations/essential_concepts>
4040
Creating animations from scratch <animations/creating_animations_from_scratch>
4141
Exporting animations <animations/exporting_animations>
42+
Optimizing animations <animations/optimizing_animations>
4243
Animating sound and particle effects <animations/animating_sound_and_particle_effects>
4344
Physics simluation <animations/physics_simulation>
4445
```

0 commit comments

Comments
 (0)