meshoptimizer icon indicating copy to clipboard operation
meshoptimizer copied to clipboard

gltfpack: Remove duplicated frames from animation

Open kzhsw opened this issue 5 months ago • 2 comments

Motivation: Currently gltfpack optimizes animation with a fixed-fps mode, which causes duplicated frames for slow animations, or animations that have a long duration. Taking this model as an example, optimizing it with gltfpack -i untitled.glb -o untitled_gltfpack.glb , the optimization not only makes the model larger (from ~72k to ~90k), but also make keyframe count increases from 4492 to 5615. In some cases this could hurt storage and memory. untitled.zip untitled_gltfpack.zip

Proposal: Remove duplicated frames from animation. Here "duplicated frames" means frames that contribute nothing or very few to the animation. If a frame can be interpolated by the frame before and the frame after it, then it's duplicated. Here are examples frames with LINEAR interpolation:

input 1 2 3
output (1,1,1) (2,2,2) (3,3,3)

Here the frame with input 2 can be linearly interpolated by the frame before and the frame after it, so it's duplicated.

glTF-Transform has implemented this algorithm here with docs here, and here is a impl in c for refrerence.

A command option is needed to switch on this feature, and another optional one for configuring tolerance.

Alternatives: 2-passes, first use gltfpack, and second use glTF-Transform.

kzhsw avatar Sep 12 '24 03:09 kzhsw