-
Notifications
You must be signed in to change notification settings - Fork 485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gltfpack: Remove duplicated frames from animation #766
Comments
I agree this can be beneficial. However, this also may not be. gltfpack uses the fixed rate resampling strategy to ensure that the time can be shared across all tracks. The extra redundancy in the data can be a problem, but it's partially mitigated by compression ( Another potential problem I've seen with systems like this in the past is that the error introduced during tolerance based resampling accumulates through a hierarchy, which can lead to extra small movement of bones that are not supposed to move; the common example is feet not being firmly planted on the ground. For animations with just a single track this is probably almost always a good idea, although I think compression efficiency is reduced on data with gaps so this would need to be verified. Ideally this should be tested on some real world animation data to see how many keyframes this saves and how often this leads to splitting the time tracks, to determine if this is broadly beneficial, and validate the hierarchical error to see how low the tolerance can be driven while avoiding that on deep bone chains. |
Alright, a couple notes since I looked into this a little bit.
junkrat without compression: current 54944 bytes, pruned 44520 bytes rubyrose without compression: current 118580 bytes, pruned 75064 bytes That said, this is with limited input sharing between tracks (only consecutive tracks share inputs) so these can be improved a little bit perhaps. But these results make me think this optimization needs to be more limited to account for the extra cost of the inputs. |
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: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.
The text was updated successfully, but these errors were encountered: