FBX Exporter: Wrong Bake Animation #104978

Open
opened 2023-10-30 15:02:41 +01:00 by Grigoriy Titaev · 8 comments

System Information
Operating system: Windows 10

Blender Version
Broken: 3.6.5, 4.0.0 (2023-10-30)

Short description of error
Wrong Bake Animation in FBX Exporter.

Exact steps for others to reproduce the error

  1. Open test file: Test Export.blend
  2. Export all meshes to FBX
    Export.png
  3. Import FBX to Blender: Test Export.fbx
  4. Compare frame 180:
    Test Export Compare.png
**System Information** Operating system: Windows 10 **Blender Version** Broken: 3.6.5, 4.0.0 (2023-10-30) **Short description of error** Wrong Bake Animation in FBX Exporter. **Exact steps for others to reproduce the error** 1. Open test file: [Test Export.blend](/attachments/5147a372-13f8-4cfc-ba43-2e699e58019c) 2. Export all meshes to FBX ![Export.png](/attachments/c34d1e6a-f216-42d9-b6f6-029908ed309d) 3. Import FBX to Blender: [Test Export.fbx](/attachments/7c3871b4-6850-44ac-929e-5088b573d51d) 4. Compare frame 180: ![Test Export Compare.png](/attachments/72b03251-c9d0-4ff6-b9ca-d0993fa758a9)
Grigoriy Titaev added the
Status
Needs Triage
Priority
Normal
Type
Report
labels 2023-10-30 15:02:42 +01:00
Member

Appears to be an export issue because other external software import the .fbx the same as Blender. Also present in 4.1.0a (FBX IO version 5.8.8).

The meshes are all parented to an animated Empty Object. Including Empty Objects in the export results in the animation exporting correctly.

Notably, each Mesh Object's .matrix_parent_inverse is not the identity matrix. Clearing the parent inverse of each Mesh Object with Object>Parent>Clear Parent Inverse will result in a correct export even when Empty Objects are not exported, but clearing the parent inverse will put the meshes in the wrong positions so it's not a solution to this issue.

Appears to be an export issue because other external software import the .fbx the same as Blender. Also present in 4.1.0a (FBX IO version 5.8.8). The meshes are all parented to an animated Empty Object. Including Empty Objects in the export results in the animation exporting correctly. Notably, each Mesh Object's `.matrix_parent_inverse` is not the identity matrix. Clearing the parent inverse of each Mesh Object with `Object`>`Parent`>`Clear Parent Inverse` will result in a correct export even when Empty Objects are not exported, but clearing the parent inverse will put the meshes in the wrong positions so it's not a solution to this issue.

Including Empty Objects in the export results in the animation exporting correctly.

Sometimes not, there is another offset.

Test Files:

Blender Version: 3.6.5, 4.0.0 Beta (2023-10-30), 4.1.0 Alpha (2023-10-30)

Test Export 2.png

> Including Empty Objects in the export results in the animation exporting correctly. Sometimes not, there is another offset. Test Files: - [Test Export 2.blend](/attachments/3774e896-e5e2-48ed-ac82-73f0c62521b7) - [Test Export 2 - Mesh.fbx](/attachments/f94320b3-d88c-4bd6-9f20-fec17606c148) - [Test Export 2 - Mesh + Empty.fbx](/attachments/60c0be68-e16e-4fda-a47c-f4439356ed11) Blender Version: 3.6.5, 4.0.0 Beta (2023-10-30), 4.1.0 Alpha (2023-10-30) ![Test Export 2.png](/attachments/51ba9f39-3e97-4b3f-aa31-8687dcb2446c)
Member

Sometimes not, there is another offset.

Test Files:

Blender Version: 3.6.5, 4.0.0 Beta (2023-10-30), 4.1.0 Alpha (2023-10-30)

The Control Empty Object makes some very small movements at frame 39 and 40. The default Bake Animation>Simplify value in the exporter does not export some of the baked keyframes because they are too similar. Disabling simplification by setting Bake Animation>Simplify to 0.0 will export every baked keyframe and the horizontal offset here disappears.

Edit: Ah, it looks like this was also the cause of the initial issue too!

> Sometimes not, there is another offset. > > Test Files: > - [Test Export 2.blend](/attachments/3774e896-e5e2-48ed-ac82-73f0c62521b7) > - [Test Export 2 - Mesh.fbx](/attachments/f94320b3-d88c-4bd6-9f20-fec17606c148) > - [Test Export 2 - Mesh + Empty.fbx](/attachments/60c0be68-e16e-4fda-a47c-f4439356ed11) > > Blender Version: 3.6.5, 4.0.0 Beta (2023-10-30), 4.1.0 Alpha (2023-10-30) > The `Control` Empty Object makes some very small movements at frame 39 and 40. The default `Bake Animation`>`Simplify` value in the exporter does not export some of the baked keyframes because they are too similar. Disabling simplification by setting `Bake Animation`>`Simplify` to `0.0` will export every baked keyframe and the horizontal offset here disappears. Edit: Ah, it looks like this was also the cause of the initial issue too!

Edit: Ah, it looks like this was also the cause of the initial issue too!

Yes, Bake Animation > Simplify = 0.0 or 0.001 solves the problem for these examples.

Field Simplify rounds the values and does not display last digits 1,2,3,4:

  • displays 0.00 for 0.004, 0.003, 0.002, 0.001
  • displays 0.000 for 0.0004, 0.0003, 0.0002, 0.0001
  • displays 0.0000 for 0.00004, 0.00003, 0.00002, 0.00001

It is better to make this field display the full value without rounding.

The Control Empty Object makes some very small movements at frame 39 and 40.

The Control Empty Object -> Rotation Y:
Frame 20 = 0 degrees, Frame 21 = -0.6525 degrees, Difference = 0.6525 degrees.
Frame 39 = -89.3475 degrees, Frame 40 = -90 degrees, Difference = 0.6525 degrees.
Frames 20-21 and 39-40 have same rotation, frame 21 is exported correctly, but frame 40 is exported incorrectly.

In blend file in frames 20-40 the rotation was only on the Y axis.
But after exporting to FBX file with Simplify = 1.0 we have changed values for X and Z axes in frame 40:

  • Rotation X was 0 degrees in blend file and became 85.986 degrees in FBX file.
  • Rotation Z was 90 degrees in blend file and became 3.6594 degrees in FBX file.

File with the original test animation and imported from FBX: Test Export 2 - Compare.blend

Test Export 2 - Compare.png

> Edit: Ah, it looks like this was also the cause of the initial issue too! Yes, `Bake Animation` > `Simplify` = 0.0 or 0.001 solves the problem for these examples. Field `Simplify` rounds the values and does not display last digits 1,2,3,4: - displays `0.00` for `0.004`, `0.003`, `0.002`, `0.001` - displays `0.000` for `0.0004`, `0.0003`, `0.0002`, `0.0001` - displays `0.0000` for `0.00004`, `0.00003`, `0.00002`, `0.00001` It is better to make this field display the full value without rounding. > The `Control` Empty Object makes some very small movements at frame 39 and 40. The `Control` Empty Object -> Rotation `Y`: Frame 20 = 0 degrees, Frame 21 = -0.6525 degrees, Difference = 0.6525 degrees. Frame 39 = -89.3475 degrees, Frame 40 = -90 degrees, Difference = 0.6525 degrees. Frames 20-21 and 39-40 have same rotation, frame 21 is exported correctly, but frame 40 is exported incorrectly. In blend file in frames 20-40 the rotation was only on the `Y` axis. But after exporting to FBX file with `Simplify` = 1.0 we have changed values for `X` and `Z` axes in frame 40: - Rotation `X` was 0 degrees in blend file and became 85.986 degrees in FBX file. - Rotation `Z` was 90 degrees in blend file and became 3.6594 degrees in FBX file. File with the original test animation and imported from FBX: [Test Export 2 - Compare.blend](/attachments/69c8ff8b-9e61-46a2-aabb-23163fcb2291) ![Test Export 2 - Compare.png](/attachments/d8ed58f7-3030-47f9-8f98-f8ce55dfcdd7)
Member

In blend file in frames 20-40 the rotation was only on the Y axis.
But after exporting to FBX file with Simplify = 1.0 we have changed values for X and Z axes in frame 40:

Rotation X was 0 degrees in blend file and became 85.986 degrees in FBX file.
Rotation Z was 90 degrees in blend file and became 3.6594 degrees in FBX file.

Unfortunately, comparing rotations before export and after importing the exported .fbx isn't very useful.

Initially, there is an axis conversion on export to .fbx by default, but on top of that, the way Blender and FBX store Object transformations is very different and there's no guarantee that the imported transformations will match what they were when they were exported. Consider this simplified example of two different rotations that result in the same transformation, where exporting as .fbx and then importing again will set both to the same rotations:
image

The animation simplification runs on the animated transformations after their conversion to the FBX format, so there's no way to see which keyframes were simplified from within Blender. If the simplification were to leave only FBX y rotation on a frame, that could still result in x, y and z Blender rotation after conversion.

I don't think there's any bug here, it is an unfortunate consequence of Blender and FBX being different formats.

> In blend file in frames 20-40 the rotation was only on the Y axis. > But after exporting to FBX file with Simplify = 1.0 we have changed values for X and Z axes in frame 40: > > Rotation X was 0 degrees in blend file and became 85.986 degrees in FBX file. > Rotation Z was 90 degrees in blend file and became 3.6594 degrees in FBX file. Unfortunately, comparing rotations before export and after importing the exported .fbx isn't very useful. Initially, there is an axis conversion on export to .fbx by default, but on top of that, the way Blender and FBX store Object transformations is very different and there's no guarantee that the imported transformations will match what they were when they were exported. Consider this simplified example of two different rotations that result in the same transformation, where exporting as .fbx and then importing again will set both to the same rotations: ![image](/attachments/98e90a75-132b-421b-bb90-267d29b180be) The animation simplification runs on the animated transformations after their conversion to the FBX format, so there's no way to see which keyframes were simplified from within Blender. If the simplification were to leave only FBX `y` rotation on a frame, that could still result in `x`, `y` and `z` Blender rotation after conversion. I don't think there's any bug here, it is an unfortunate consequence of Blender and FBX being different formats.
145 KiB

Another example:

  1. Create Object
  2. Set Object Rotation Z = 90 degrees
  3. Animate Rotation Y: Frames 0-10, Rotation Y from 0 to 90 degrees
  4. Create a gap in the animation: Frames 10-90, Without animation
  5. Animate Rotation Y: Frames 90-100, Rotation Y from 90 to 0 degrees
  6. Export FBX with Simplify = 1.0
  7. Import FBX
  8. Imported object for frames 10-90 have the wrong animation, although it was not in the original animation.
    Something wrong is happening with the Rotation in frames 10 and 90. Test Cube.blend

Test Cube.png

Export FBX with Simplify = 1.0, 0.1, 0.01 has this problem.
Export FBX with Simplify = 0.001 can fix it.

If Blender can not import this FBX file correctly, it means that other user programs may also have problems with importing such FBX files.

This problem in the above examples happens in the first and last frames in the gap between the rotation animations.

If it's hard to fix or it's not a bug, then I propose change the default value for the Simplify field from 1.0 to 0.001, because something is not working properly with Simplify = 1.0.

Another example: 1. Create Object 2. Set Object Rotation `Z` = 90 degrees 3. Animate Rotation `Y`: Frames 0-10, Rotation `Y` from 0 to 90 degrees 4. Create a gap in the animation: Frames 10-90, Without animation 5. Animate Rotation `Y`: Frames 90-100, Rotation `Y` from 90 to 0 degrees 6. Export FBX with `Simplify` = 1.0 7. Import FBX 8. Imported object for frames 10-90 have the wrong animation, although it was not in the original animation. Something wrong is happening with the Rotation in frames 10 and 90. [Test Cube.blend](/attachments/c27c9c2f-9269-4c64-933f-c354fac4cf00) ![Test Cube.png](/attachments/4293db01-3d3a-4d40-b64d-a6d27a6eb98c) Export FBX with `Simplify` = 1.0, 0.1, 0.01 has this problem. Export FBX with `Simplify` = 0.001 can fix it. If Blender can not import this FBX file correctly, it means that other user programs may also have problems with importing such FBX files. This problem in the above examples happens in the first and last frames in the gap between the rotation animations. If it's hard to fix or it's not a bug, then I propose change the default value for the `Simplify` field from 1.0 to 0.001, because something is not working properly with `Simplify` = 1.0.

Hi @Mysteryem , I absolutely agree with @gtitaev that the default settings should change, because you cannot count on every artist will read the settings and documentations properly, 80% of artists will simply click the confirm button and call it a day.

Just because they didn't change the settings properly, thus a feeling that blender is not suit for production pipeline. If the default settings for fbx i/o can be changed to a more reasonable config, people all over the world will find blender can export fbx with no problem at all.

Here is a camera i/o version of the same issue opened by me#105058

Hi @Mysteryem , I absolutely agree with @gtitaev that the default settings should change, because you cannot count on every artist will read the settings and documentations properly, 80% of artists will simply click the confirm button and call it a day. **Just because they didn't change the settings properly**, thus a feeling that blender is not suit for production pipeline. If the default settings for fbx i/o can be changed to a more reasonable config, people all over the world will find blender can export fbx with no problem at all. Here is a camera i/o version of the same issue opened by mehttps://projects.blender.org/blender/blender-addons/issues/105058
Member

I'm not saying whether I think the default settings should or should not be changed, just that, given how the simplification process works and the default export settings, I would say this behaviour is expected.

For your own export process, I would recommend setting your own Operator Preset with your desired export settings. For example, I work with Unity a lot, so I use a Preset with Transform>Apply Scalings set to FBX All to prevent my armatures being scaled up 100 times when imported into Unity.

I think the simplification function could definitely be improved (the Graph Editor has some nice operators for decimating curves, but they can't be used easily from addons and FBX I/O currently only supports exporting keyframes with linear interpolation), but FBX I/O doesn't really see any development outside of bug fixes and community contributions (which includes myself).

If you want to contribute, the wiki can get you started https://wiki.blender.org/wiki/Developer_Intro, but otherwise the issue trackers aren't really for feedback and features requests: https://wiki.blender.org/wiki/Communication/Contact#User_Feedback_and_Requests

I'm not saying whether I think the default settings should or should not be changed, just that, given how the simplification process works and the default export settings, I would say this behaviour is expected. For your own export process, I would recommend setting your own Operator Preset with your desired export settings. For example, I work with Unity a lot, so I use a Preset with `Transform`>`Apply Scalings` set to `FBX All` to prevent my armatures being scaled up 100 times when imported into Unity. I think the simplification function could definitely be improved (the Graph Editor has some nice operators for decimating curves, but they can't be used easily from addons and FBX I/O currently only supports exporting keyframes with linear interpolation), but FBX I/O doesn't really see any development outside of bug fixes and community contributions (which includes myself). If you want to contribute, the wiki can get you started https://wiki.blender.org/wiki/Developer_Intro, but otherwise the issue trackers aren't really for feedback and features requests: https://wiki.blender.org/wiki/Communication/Contact#User_Feedback_and_Requests
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 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#104978
No description provided.