Unexpected Keyframes when exporting FBX with ShapeKeys #104424

Open
opened 2023-02-20 03:40:06 +01:00 by Saberpeep · 3 comments

System Information
Operating system: Windows 11 Home 22H2
Graphics card: Nvidia Geforce RTX 3080

Blender Version
Broken: 3.3.3 LTS, 8d94aeb604fa, master, 2023-01-17 08:40
Worked: none (this has remained an issue since I starting using blender years ago)

Short description of error
When exporting geometry with shapekeys (not animated) and bone animations as an FBX file, all animation clips receive unexpected additional channels with keyframes on all shapekeys.

Exact steps for others to reproduce the error

  1. Open example file (contains simple set up with cube with armature, single bone, bone animations on NLA track, and 1 shape key).
  2. Export FBX with the following settings:
    • Bake animation
      • Key All Bones
      • NLA Strips
      • All Actions
      • Force Start/End Keying
      • Sampling Rate 1.00
      • Simplify 0.00
  3. Import FBX in any external 3D application (my testing used Unity 2019.4.31f1)
  4. See that animation clip contains an unexpected additional channel with keyframes for the shapekey(s).

Other Notes

  • The state of the 'Key All Bones' checkbox seems to have no effect.
  • With 'Force Start/End Keying' unchecked and simplify set to 1, the errant keyframes are removed, however this also removes other desired keyframes as well as entire animations where there is no change in motion.
**System Information** Operating system: Windows 11 Home 22H2 Graphics card: Nvidia Geforce RTX 3080 **Blender Version** Broken: 3.3.3 LTS, 8d94aeb604fa, master, 2023-01-17 08:40 Worked: none (this has remained an issue since I starting using blender years ago) **Short description of error** When exporting geometry with shapekeys (not animated) and bone animations as an FBX file, all animation clips receive unexpected additional channels with keyframes on all shapekeys. **Exact steps for others to reproduce the error** 1. Open example file (contains simple set up with cube with armature, single bone, bone animations on NLA track, and 1 shape key). 2. Export FBX with the following settings: - [x] Bake animation - [ ] Key All Bones - [x] NLA Strips - [ ] All Actions - [ ] Force Start/End Keying - Sampling Rate 1.00 - Simplify 0.00 3. Import FBX in any external 3D application (my testing used Unity 2019.4.31f1) 4. See that animation clip contains an unexpected additional channel with keyframes for the shapekey(s). **Other Notes** - The state of the 'Key All Bones' checkbox seems to have no effect. - With 'Force Start/End Keying' unchecked and simplify set to 1, the errant keyframes are removed, however this also removes other desired keyframes as well as entire animations where there is no change in motion.
Saberpeep added the
Type
Report
label 2023-02-20 03:40:06 +01:00
Brecht Van Lommel added the
Priority
Normal
Status
Needs Triage
labels 2023-02-21 11:20:23 +01:00
Member

@Saberpeep do you expect or want just the values to be written out without keys?
I would like you to be clear on what your expected results would be from the current settings or if you are asking for a new option to control keying for shapeKeys, so that if/when a developer can look at it, there is zero question of what needs to be done.

Thank you.

@Saberpeep do you expect or want just the values to be written out without keys? I would like you to be clear on what your expected results would be from the current settings or if you are asking for a new option to control keying for shapeKeys, so that if/when a developer can look at it, there is zero question of what needs to be done. Thank you.
Author

In this example the shapekeys are not animated. The animation in blender does not have any keyframes for the shapekeys. So therefore in the FBX export I would also expect the animation to have no keyframes for the shapekeys. And yet in the export all of them are keyed in every animation.

Keyframes for shape keys in a given animation should only exist in the FBX export if they also exist in the same animation in blender.

In this example the shapekeys are not animated. The animation in blender does not have any keyframes for the shapekeys. So therefore in the FBX export I would also expect the animation to have no keyframes for the shapekeys. And yet in the export all of them are keyed in every animation. Keyframes for shape keys in a given animation should only exist in the FBX export if they also exist in the same animation in blender.
Author

So I've done some digging into the source code of the exporter, and the issue is much larger than I thought. I'm not super fluent in python, so some of my assumptions might not be accurate. But it seems like the exporter has absolutely no concept of what keyframes belong to what animation clip or even which NLA track. It just seems to run the timeline along the length of the NLA track and records the transforms of all objects/bones, values of all shape keys, and focal distance of all cameras over time. Then once it has this massive collection of keyframes across all possible channels, it does the Simplify step to remove any keyframes that don't change.

The result is that without Simplify every animation just gets every single channel keyed (even things that weren't in the original clips such as the shapekeys). And with Simplify on, channels and even animations that are static without any changes in value are deleted entirely. I can turn on "Force Start and End Keying" to prevent the static animations from being deleted, but this of course also preserves all the unwanted channels.

The solution then would be for the exporter to at the very least limit itself to channels that actually exist in the clip (or at least the NLA track) that it is exporting. Though in an ideal world it should be exporting the exact channels and keyframes as they exist in the actual animation clips in the given NLA Track.

So I've done some digging into the source code of the exporter, and the issue is much larger than I thought. I'm not super fluent in python, so some of my assumptions might not be accurate. But it seems like the exporter has absolutely no concept of what keyframes belong to what animation clip or even which NLA track. It just seems to run the timeline along the length of the NLA track and records the transforms of all objects/bones, values of all shape keys, and focal distance of all cameras over time. Then once it has this massive collection of keyframes across all possible channels, it does the Simplify step to remove any keyframes that don't change. The result is that without Simplify every animation just gets every single channel keyed (even things that weren't in the original clips such as the shapekeys). And with Simplify on, channels and even animations that are static without any changes in value are deleted entirely. I can turn on "Force Start and End Keying" to prevent the static animations from being deleted, but this of course also preserves all the unwanted channels. The solution then would be for the exporter to at the very least limit itself to channels that actually exist in the clip (or at least the NLA track) that it is exporting. Though in an ideal world it should be exporting the exact channels and keyframes as they exist in the actual animation clips in the given NLA Track.
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#104424
No description provided.