Closed Peach1 closed 5 months ago
Yes, that's on my todo list. I got cubic spline already up and running, but I haven't had the time to polish it up. The samples from your last issue are already working.
Spare time is currently a bit limited, so it may take some time.
I have pushed a new branch that adds step and cubic spline based interpolations for animation samplers. It's still wip, but if you need a reference you may want to take a look at it.
Cubic spline interpolation should work now. I have tested with this scene: https://github.com/KhronosGroup/glTF-Sample-Assets/tree/main/Models/InterpolationTest
And every animation type worked as expected.
Vulkan-glTF-PBR is the best C++ animated glTF viewer implementation so far!
For animations, can CubicSpline and Step interpolation support be added?
Cubicspline animation doesn't currently animate because glTF cubicspline animation sampler data layout is different from linear/step (cubicspline uses additional in-tangent and out-tangent vectors)
Step animation animates, Step just needs frame interpolation turned off
*Cubicspline animation expects output3 vectors total to store the cubicspline intangent and out tangent**
"CUBICSPLINE"
The animation's interpolation is computed using a cubic spline with specified tangents. The number of output elements must equal three times the number of input elements. For each input element, the output stores three elements, an in-tangent, a spline vertex, and an out-tangent. There must be at least two keyframes when using this interpolation.(From: https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-c-spline-interpolation )
Here's a suggestion for cubicspline animation support:
Vulkan-glTF-PBR needs to write in-tangent and out-tangent when loading cubicspline animations
void loadAnimations
https://github.com/SaschaWillems/Vulkan-glTF-PBR/blob/master/base/VulkanglTFModel.hpp#L1064 should export extra intange and outtangent for the cubicspline interpolation, in addition tooutputsVec4
In
updateAnimation
https://github.com/SaschaWillems/Vulkan-glTF-PBR/blob/master/base/VulkanglTFModel.hpp#L1346Interpolation update can change to support all 3 styles
"LINEAR"
The animated values are linearly interpolated between keyframes. When targeting a rotation, spherical linear interpolation (slerp) should be used to interpolate quaternions. The number output of elements must equal the number of input elements."STEP"
The animated values remain constant to the output of the first keyframe, until the next keyframe. The number of output elements must equal the number of input elements.Here's a similar glTF cubicspline animation issue for reference: https://github.com/mrdoob/three.js/pull/12907
attached is a zip of the 3 animation sample types in glTF
glTF_3_animation_types.zip