KhronosGroup / glTF-Sample-Assets

To store all models and other assets related to glTF
257 stars 30 forks source link

Samples that demonstrate complex animation interpolation #55

Open zellski opened 7 years ago

zellski commented 7 years ago

All the skinned 2.0 models have LINEAR interpolation samplers. Wouldn't it be excellent to demonstrate the use of CUBICSPLINE and CATMULLROMSPLINE, for us folks implementing tools and renderers? <3

pjcozzi commented 6 years ago

@zellski good idea!

@McNopper does the Blender glTF exporter use CUBICSPLINE and CATMULLROMSPLINE at all? Could be an easy way to get a sample for this.

UX3D-nopper commented 6 years ago

No, as Blender only supports Constant, Linear and Bezier.

As glTF 2.0 does not support Bezier, they are converted to a linear approximation.

zellski commented 6 years ago

It's admittedly been a couple of decades, but aren't cubic Bezier and cubic Hermite representations interchangeable, with a little bit of mathematics? This is drifting from the original post, though.

In addition to upgrading our use of GLTF on the client to 2.0, I'm also working on updating our FBX to GLTF tool to 2.0. Once I've got it outputting valid data, I'll see if I can dig into all the FBX animation complexity and work out how their stacks and layers work and which FbxAnimCurves might translate to cubic spline. It seems like FBX has much more (and more complex) expressive power and we can probably only convert a small subset of configurations without sampling.

Meanwhile, if anybody else has models to contribute, I'd still be very interested...

UX3D-nopper commented 6 years ago

As far as I know, the converison result is similar but not the same. But if u can guide me to the math, I can have a look at it.

zellski commented 6 years ago

@UX3D-nopper OK, I scribbled a bit and Googled and bit, and it's an extremely simple transformation. If your cubic Bezier parameters are y0, y1, y2 and y3, and you want Hermite cubic parameters p0, m0, p1, m1, then:

p0 = y0
m0 = 3(y1-y0)
p1 = y2
m1 = 3(y3-y2)

Here's a concrete demonstration I hacked together in Desmos: https://www.desmos.com/calculator/bgaikgwcfh (Bezier) https://www.desmos.com/calculator/fs66j5b7db (Hermite)

And here's a PDF someone made with a bunch of the math in a very accessible format: http://www.academia.edu/9781223/Matrix_Form_for_Cubic_B%C3%A9zier_Curves_Converting_Between_Cubic_Spline_Types

UX3D-nopper commented 6 years ago

Thank you very much for the math. Learned something :-)

Will add it: https://github.com/KhronosGroup/glTF-Blender-Exporter/issues/40

UX3D-nopper commented 6 years ago

I will check, how much code needs to be changed but we will probably implement after SIGGRAPH. See the discussion here: https://github.com/KhronosGroup/glTF-Blender-Exporter/issues/39 I agree, that this one of the most important future features of the exporter, but before SIGGRAPH, we do not want to break code.

zellski commented 6 years ago

Totally understood. You're already ahead of the curve. For example, three.js GLTF2Loader can't even cope with these interpolation modes yet. Good luck at SIGGRAPH!

UX3D-nopper commented 6 years ago

Thank you. I will not be personally at SIGGRAPH, but a lot of others from the glTF 2.0 working group. The guys from three.js seem to use the exporter quite intensive, so we try to minimize the changes and focus more on the documentation and tests. Also regarding the feedback we get, other individuals and companies use it quite often as well. Close before SIGGRAPH, we will tag a version and then the exporter is again a sandbox. E.g. I want the morph targets to use sparse accessors and implement the other listed enhancements.

UX3D-nopper commented 6 years ago

Okay, started with it: https://github.com/KhronosGroup/glTF-Blender-Exporter/commit/3180b08e44dc997d65d8081d5c0fb57ea8bc6a29

Sample files can be found here: https://github.com/KhronosGroup/glTF-Blender-Exporter/tree/master/scenes 01cs*.blend

You need Blender 2.79 RC for the files.

prideout commented 4 years ago

Also note that InterpolationTest.gltf in the conformance suite exercises CUBICSPLINE, but does not animate morph weights. I think it would be good to animate morph weights since the memory layout for animated morph weights is not obvious.

DRx3D commented 8 months ago

There has been no activity in over 3 years. It appears that there is still an open discussion. This can be moved to the new glTF-Sample-Assets repo if further discussion or consideration is desired. That is the default disposition for this issue.