Skip to content
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: Disable animation resampling when frequency is 0 #819

Merged
merged 4 commits into from
Dec 11, 2024

Conversation

zeux
Copy link
Owner

@zeux zeux commented Dec 10, 2024

Using -af 0 now disables resampling and keeps the original time values.

When resampling is disabled, we can still mark tracks as constant and
remove them if they are not necessary, which cuts down on the animation
size. In this mode it is more difficult to support ranges, so we assume track
range will cover the relevant timespan if any tracks with time survive.

Doing this analysis for cubic splines is slightly more difficult as if
tangents are non-zero, an otherwise "constant" track will not result in
constant output, so we disable analysis in that case for simplicity.

Fixes #815.

zeux added 2 commits December 10, 2024 09:59
This allows more flexibility in processing the animations before
serialization. When the track time is present, we write it instead of a
fixed-rate frequency track.

For now no attempt to deduplicate time tracks is taken; this could be
added in the future if need be, but the assumption is that the more
optimal way to serialize tracks with shared time ranges is to use
resampling anyway.
Tracks with cubic splines have three output components for each input
component; also, they require writing interpolation type properly.

When serializing cubic spline tracks for rotations, the tangents are not
actually quaternions; as such, they can't be encoded using quaternion
filter, and in -cc mode we need to fall back to raw snorm encoding. Even
snorm encoding technically might not be sufficient as tangents could be
outside of -1..1 range, but for now we can probably clamp out of range
tangents.
@zeux zeux force-pushed the gltf-animfreq branch 2 times, most recently from cf16c38 to d4759fc Compare December 10, 2024 20:37
Using -af 0 now disables resampling and keeps the original time values.

When resampling is disabled, we can still mark tracks as constant and
remove them if they are not necessary, which cuts down on the animation
size. In this mode it is more difficult to support ranges, so we assume track
range will cover the relevant timespan if any tracks with time survive.

Doing this analysis for cubic splines is slightly more difficult as if
tangents are non-zero, an otherwise "constant" track will not result in
constant output, so we disable analysis in that case for simplicity.
When tracks have custom time inputs (and resampling is disabled), we can
reuse inputs when they are equal between two tracks. This sharing is
only performed between consecutive tracks as it allows us to still
process tracks linearly.
@zeux zeux changed the title gltfpack: Implement support for disabling resampling when frequency is 0 gltfpack: Disabling animation resampling when frequency is 0 Dec 11, 2024
@zeux zeux changed the title gltfpack: Disabling animation resampling when frequency is 0 gltfpack: Disable animation resampling when frequency is 0 Dec 11, 2024
@zeux zeux merged commit 28549cb into master Dec 11, 2024
12 checks passed
@zeux zeux deleted the gltf-animfreq branch December 11, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gltfpack: Animation without resampling
1 participant