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

Animation sampler LINEAR rotation interpolation, SLERP and the shortest path #2073

Closed
atteneder opened this issue Oct 12, 2021 · 2 comments
Closed

Comments

@atteneder
Copy link
Contributor

The specification says the following about LINEAR quaternion interpolation:

When targeting a rotation, spherical linear interpolation (slerp) SHOULD be used to interpolate quaternions

I assume this is no hard requirement (not a "MUST") in order to not exclude animation systems that interpolate quaternions via N-LERP (component-wise LERP). N-LERP does not give the same result, but might be close enough while requiring less computation.

However, most SLERP implementations handle cases where the angle between the two quaternions is not the shortest path (so bigger than 180 degrees) gracefully by calculating the shortest-path (see this post). N-LERP will fail miserably in that case and create ugly glitches (e.g. this issue).

The solution is to properly re-calculate (flip) adjacent rotations where this occurs, which can be done either at the export/generation of the glTF or at run-time.

Depending on the preferred solution the specification should

  1. Clarify that exporters are required to make sure adjacent rotations have an angle of 180 degree or lower
  2. Recommend (non-normative) that importers have to take care of calculating/certifying the shortest-path interpolation in their SLERP/N-LERP implementations.

I'd personally prefer if this is required upon export (since the T in glTF stands for transmission and run-time overhead should be kept at a minimum), but I recognize this might be a breaking change for the spec.

Thanks for considering!

P.S.:
Exporters I observed to not make sure rotations are shortest-path (by checking the asset->generator property):

  • babylon.js glTF exporter for Autodesk Maya 2020.4 v20210811.2 as well as v20210615.1
  • Khronos glTF Blender I/O v1.6.16
@lexaknyazev
Copy link
Member

Duplicate of #1395. The Section C.4 covers this now.

@atteneder
Copy link
Contributor Author

@lexaknyazev,

Sorry I missed that and thanks for pointing me towards it.

While I'm glad to see it is covered, I'm also somewhat disappointed it's not recommended/required from exporters.

Maybe a target for glTF 3.0 and a glTF validator informational message.

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

No branches or pull requests

2 participants