SaschaWillems / Vulkan-glTF-PBR

Physical based rendering with Vulkan using glTF 2.0 models
MIT License
977 stars 130 forks source link

Animation Samplers CubicSpline & Step #25

Closed Peach1 closed 5 months ago

Peach1 commented 5 years ago

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**

(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 to outputsVec4

In updateAnimation https://github.com/SaschaWillems/Vulkan-glTF-PBR/blob/master/base/VulkanglTFModel.hpp#L1346

Interpolation update can change to support all 3 styles

if cubicspline
   cubic bezier interpolation
else if linear
   mix/lerp
else if step
  like linear, just without mix/lerp

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

SaschaWillems commented 5 years 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.

SaschaWillems commented 5 years ago

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.

SaschaWillems commented 5 months ago

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.