Maniphest T73863

Spline IK 'Fit Curve' scaling incorrect on FBX export
Confirmed, NormalKNOWN ISSUE

Assigned To
None
Authored By
Philip Guin (Frizzil)
Feb 16 2020, 2:12 AM
Tags
  • Import/Export
  • Add-ons (BF-Blender)
Subscribers
Aleksandr (viadvena)
AM (Ali_cirox)
hufeng (hufeng1985923)
Jan Schneider (jacasch)
Philip Guin (Frizzil)
Tokens
"Burninate" token, awarded by Ali_cirox."Burninate" token, awarded by viadvena.

Description

System Information
Operating system: Windows-10-10.0.18362-SP0 64 Bits
Graphics card: GeForce GTX 970/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 432.00

Blender Version
Broken: version: 2.82 (sub 7), branch: master, commit date: 2020-02-12 16:20, hash: rB77d23b0bd76f

Short description of error
FBX export of a typical Spline IK with non-uniform scaling options (e.g. Fit Curve) gives incorrect results. Baking via F3 -> Bake Action did NOT reproduce the issue.

Problem has apparently been bugging people for a while (see this thread and this video for an example.) A suggested fix is to duplicate the bone chain, remove all parenting and constraints from the new chain and add "Copy Transform" constraints from each new bone to the original. Due to animation baking, I can confirm this does initially appear to work, however: it removes parenting information in the final export, meaning that even with baking, blending between multiple animations will fail completely.

Exact steps for others to reproduce the error

  1. Load the attached .blend file.
  2. Hit Space to play the current action. Notice the correct shape of the animated noodle poses.
  3. Navigate to File -> Export -> FBX.
    1. Under Transform, set 'Apply Scalings' to 'FBX Units scale'
    2. Under Armature, enable 'Only Deform Bones' and disable 'Add Leaf Bones'
    3. Make an Operator Preset to save some trouble.
    4. Hit 'Export FBX'.
  4. Open the exported FBX in Windows 3D Viewer, or whatever application you prefer.
  5. Notice incorrect animated noodle poses.

Blend File:

Broken FBX:

Expected poses:

Result poses:

Comments
I'm not familiar with the source, but in the FBX exporter plugin, a place to look may be in file fbx_utils.py, function fbx_object_matrix, possibly not accounting for the Inherit Scale option. It's pretty hard to decipher without knowing the plugin well, however.

Thanks for your time.

Event Timeline

Philip Guin (Frizzil) created this task.Feb 16 2020, 2:12 AM
Philip Guin (Frizzil) updated the task description.Feb 16 2020, 2:15 AM
Philip Guin (Frizzil) updated the task description.Feb 16 2020, 4:31 AM
Richard Antalik (ISS) changed the task status from Needs Triage to Confirmed.Feb 17 2020, 12:43 PM
Richard Antalik (ISS) edited projects, added Import/Export, Add-ons (Community); removed BF Blender.
Richard Antalik (ISS) changed the subtype of this task from "Report" to "Known Issue".
Philip Guin (Frizzil) added a comment.Feb 18 2020, 12:21 AM

Thanks for acknowledging this issue, hopefully someone takes a look at it soon! If I get some time, I might see if I can get involved, though I'd specifically want to work on this problem.

Also, I haven't tested this, but I suspect it may be affecting non-uniform scale in exported animations unrelated to the Spline IK. If true, I imagine that would affect priority.

As to evaluating importance: as a game dev, this is completely blocking my ability to have "squash and stretch" animations on my main character model (which if you're Disney, is an important feature!) Anyone modeling a creature or humanoid with a tail may also be blocked by this, as evidenced by discussion of this issue on other platforms. And if it's blocking all non-uniform scale, then that's a huge feature that both UE4 and Unity support, and game developers would be missing out on.

Godspeed, Blender devs!

Bastien Montagne (mont29) added a project: Python API.May 27 2020, 6:28 PM
Bastien Montagne (mont29) merged a task: T71449: Spline Ik Export Fbx or DAE shows wrong result.
Bastien Montagne (mont29) added a subscriber: hufeng (hufeng1985923).
Bastien Montagne (mont29) mentioned this in T68575: FBX Known issues & TODO's.May 27 2020, 6:30 PM
Philip Guin (Frizzil) added a comment.May 28 2020, 12:12 AM

I should give an update, this may help in decision-making:

I went through the trouble of cloning the Blender repo and trying to fix this issue, which turned out to involve "Non-Uniform Scale Inheritance." As it just so happens, FBXNode has an attribute for this, "TransformInheritType", that can be set to one of three values, RrSs = 0, RSrs = 1, Rrs = 2. (See here, but search for "Transformation Propagation") In the current build, it's always set to RSrs, and the output transforms implicitly assume this inheritance type as they're computed. When I modified the code to output the correct inheritance type, and compute the transform accordingly, something interesting happened. I opened it up in Unity and got this warning:

ImportFBX Warnings:
File contains 7 (out of 11) nodes with Scale Compensation. Scale Compensation is not supported by Unity (because it works differently in 3dsMax and Maya). This might result in scale imported incorrectly, if this happens try disabling Scale Compensation in your file.

It was also very, very incorrect. I got much better results in Windows 3D Viewer, however, but still incorrect. (Ultimately I have no idea if my transforms were actually correct, but I don't know of a way to verify besides heavily modifying my game engine, which is not independently reproducible.) This leads me to believe that scale compensation is not a well supported feature, and an effort to add it to Blender might also necessitate an effort to add it to other software packages.

The best approach? We could add it to Blender but leave a checkbox to "Disable Scale Compensation", checked by default. Then everyone's happy - if some software package or game developer (like yours truly) wants to use Scale Inheritance as documented by FBX, they can; and other packages can stay the same, or migrate to the "correct" method over time.

Now, we could do nothing... but like I said before, that's a major feature that these engines claim to support, and it would be great to have for "toon-like" animation. In any case, Disney thought it was important enough to invent and publish their own algorithm for visualizing it in real-time, for artists working on Frozen.

More research should probably be done on this. Also, I can post my source changes and/or exported models with "Scale Compensation" if needed. Thanks for reading.

Campbell Barton (campbellbarton) moved this task from Backlog to Under Discussion on the Python API board.Jun 18 2020, 3:15 PM
Campbell Barton (campbellbarton) removed a project: Python API.Jun 18 2020, 3:46 PM
Bastien Montagne (mont29) edited projects, added Add-ons (BF-Blender); removed Add-ons (Community).Jul 28 2020, 11:02 AM
Bastien Montagne (mont29) moved this task from Backlog to Long Term on the Add-ons (BF-Blender) board.Jul 28 2020, 11:08 AM
Aleksandr (viadvena) awarded a token.Sep 29 2020, 12:17 PM
Aleksandr (viadvena) added a subscriber: Aleksandr (viadvena).Sep 29 2020, 1:43 PM

Looks like Blender has big problem with scale. SplineIK, Stretch To - completely unusable and useless for export. No controlled ropes, no controlled tails. Rigify due this issue is also damaging bones and corrupt animation. It's sad that fundamental issues does not resolving for so long time. Where is Animation 2020?)
Blender can not handle standard animation tricks. I think there is no place for new features until so big issues will be resolved.

Jan Schneider (jacasch) added a subscriber: Jan Schneider (jacasch).Dec 18 2020, 10:03 AM

I can confirm, that the Spline IK Baking is broken.
I had a fairly long chain ofbones (~30) and when baking the animation, the tip of the cian was just everso slightly off to not match with other animations.
I managed to solve it in the end by creating a second chain of bones, then clearing all the parents, and then constraining the with a "copy transform ocnstriant" to the corresponding bone in the spline ik chain.
Its an ugly hack, but it works.

Is is possible that when baking rotation (or saving it to fbx in that matter) somehow reduces accuracy in the numbers that store rotation? if so this would make sense, as small inaccuracies woul acumulate through the bone chain. but i am no expert, just a guess

Aleksandr (viadvena) added a comment.Oct 5 2021, 7:38 PM

Is there some hope for 3.0? This constraint doesn't work for game engines and this is big deal...

AM (Ali_cirox) awarded a token.Dec 4 2021, 4:29 PM
AM (Ali_cirox) added a subscriber: AM (Ali_cirox).
AM (Ali_cirox) added a comment.EditedDec 4 2021, 4:36 PM

This is not only a FBX-Export (Add-On) Problem, but also a Object > Animation > Bake Action Problem. ("Bastien Montagne (mont29) moved this task from Backlog to Long Term on the Add-ons (BF-Blender) board.")
wich is very unfortunate, because with this issue, spline IK is only usable with y-scale = original bone scale and nothing else.

Personally i need it for a game engine workflow and didnt expect it to fail at that stage.