2
$\begingroup$

I created a simple animation with shape keys. However exporting this animation not working properly. After I export it in gltf2 or fbx format, the shape keys are reset to 0 in exported file. What causes that? Probably this is a bug, but I wonder if there is a working workaround.

This is the animation I created:

shape key animation

This is the shape key value after exporting then importing: enter image description here

Update: Using emackey's advice I switch my shapekeys to "relative". But also I had to change each shapekey's "relative to"'s to one previous shape key. Even though shapekeys and keyframes exported correctly, this time their relative to's exported wrong. All of the shapekey's "relative to"s set as basis.

$\endgroup$
0
$\begingroup$

If you want shape key animation to be exported with an FBX or GLTF format the shape key needs to be driven by a bone, otherwise the shape key will have to be animated programmatically. The shape key is still there you are just not seeing the animation.

If you were to bring this cube into Unity as an FBX the shape key will show up as a Blendshape but won't be animated I believe it may be similar for GLTF format.

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Actually glTF should support animated shape keys. It's in the test suite and should survive round-trip. $\endgroup$ – emackey Jan 16 at 14:23
  • $\begingroup$ I would recommend checking out emackeys Blend file example, export using Blenders default GLTF settings ( change the format to GLTF embedded or GLTF separate) and you can drag and drop the files in a viewer like this gltf-viewer.donmccurdy.com $\endgroup$ – Chris Jan 16 at 17:02
0
$\begingroup$

There's an example of shape keys round-tripping (glTF to Blender to glTF) in the glTF-Blender-IO test suite, which is a collection of .blend files and .gltf files that are used by an automated process to put new versions of the Blender glTF importer/exporter through most of its paces.

The tests/roundtrip/01_cs_morph folder contains a glTF file that is imported and then re-exported, and is expected to preserve the glTF "morph" animation via Blender's shape key animations.

There is also a tests/scenes/01_cs_morph.blend file that is tested via the exporter. This is a Blender 2.79 project, but the test suite loads it into 2.82 beta (currently) and expects it to export correctly. You can download the blend file to see how these shape keys look in any recent version of Blender.

It's not clear from the OP screenshots what the problem is there, but start by taking a look at the examples from the test suite to see how it's supposed to work. If you still have a case where it's broken, please file an issue and include a sample project for testing.

|improve this answer|||||
$\endgroup$
  • 1
    $\begingroup$ So, the blend file you shared has shape_key with relative checkbox checked. So it has no problem. There is a problem when that box is unchecked. When it is unchecked, shapekeys are reset to zero. $\endgroup$ – user1559792 Jan 16 at 18:25
  • $\begingroup$ Interesting. glTF stores "morph targets" as deltas from a base position, so Blender's "relative" shape keys are probably a better match for what glTF does internally. Even so, relative values should be easy to compute given absolute values. You could add an issue to the tracker requesting support for non-relative shape keys. (They would still round-trip to be relative ones of course). $\endgroup$ – emackey Jan 16 at 19:51
0
$\begingroup$

I found a workaround solution. When "relative" checkbox is unchecked, the shape keys are not exported properly. If "relative" checkbox is checked and "relative to"s of shape keys are set other than basis, it will be reset to basis. So I adjusted my animation to dodge those bugs. I kept "relative" checkbox checked and left "relative to"s as "basis". I wrote a script that puts keyframes in timeline and iterates through shape keys and keyframes, sets value of current shape key as 1 and others as 0 on current keyframe.

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.