KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.48k stars 316 forks source link

Prevent Frame interpolation #2137

Open yellowborb opened 6 months ago

yellowborb commented 6 months ago

I would like to prevent Frame interpolation and force the animation of my glb to respect its initial framerate.

I can do that in the maya2gltf pluging and I would love to be able to do the same in blender, here is a picture of the arguments that allows me to do that in Maya (I think the -dsa is the most important)

dsa

An example of why this is important : If I animate an object disappearing from one frame to another by setting the scale from 1 to 0, then the interpolation will break the animation showing it scaling up or down. Thanks !

julienduroure commented 6 months ago

Hello,

I would like to prevent Frame interpolation

Any animation in CONSTANT interpolation in Blender should export using STEP in glTF. All component (for example scale.x scale.y scale.z) must have the same interpolation, to be sure to handle it correctly

Can you please upload an example test file where you struggle to export it correctly?

force the animation of my glb to respect its initial framerate

I maybe misunderstand what you mean, but you should be able to choose your sampling rate here: image

Same here, in case of issue, can you provide a simple example.blend file?

f3lix-s commented 6 months ago

I had once "trouble" with frame interpolation, when I had a looping animation build with a "Cycles" fcurve modifier.

looping_fcurves

The result was something like this: after the torus scaled out of view, it scaled back to zero and over again ...

https://github.com/KhronosGroup/glTF-Blender-IO/assets/75536166/9314b927-5952-4d57-96cd-20647551b531

What i did, was baking the animation and then export the scene as .glb. Resulting problem was the interpolation on the way back to zero.

https://github.com/KhronosGroup/glTF-Blender-IO/assets/75536166/f7f70847-6f7d-433c-ab67-e8c30437190e

My solution was changing the fcurve interpolation to "constant" This resulted in a somewhat strange looking fcurve for a smooth movement,

fcurve

but worked out for my needs.

Maybe the opportunity to bake animation modifiers, like "Apply Modifier" in Mesh, would be a helpful feature. "Bake All Object Animations" in export settings didn't do the job for me.

With this feature it would maybe make sense to have the choise during export to define the interpolation method, so you can keep the Animation Modifiers, without baking the Animation before exporting. Or maybe it would make sense to set interpolation to constant/step if there is a key on every frame.

Final thoughts: For me it is fine like it is, but when i encountert the interpolation problem it took me some time to think about a possible solution.

julienduroure commented 5 months ago

Hello, This case is quite interesting.

First, some note about glTF Specification :

So :

I don't think we can use check that the curve has a key on every frame, as export will convert it to second, and result will depend on the framerate.

So ... no easy answer with this case