Baking animation of bones affected by a curve (spline IK) is wrong #79670

Open
opened 2020-08-09 17:44:56 +02:00 by Gabriel · 18 comments

System Information
Operating system: windows 10
Graphics card: gforce 1060 6gb

Blender Version
Broken 2.92 alpha
Broken 2.83
Worked: likely never

Short description of error
I have a row of bones, I add the curve modifier, I make an animation with that modifier on, I bake the animation of the bones to be able to send it to unreal or unity and the animation breaks completely

Exact steps for others to reproduce the error
CurveBreackExample.blend

  • Open file
  • inspect wrong bake of bone action
  • to reproduce:
  • go to object mode
  • select SkeletonBase object
  • go to pose mode (all bones should be selected)
  • Pose > Animation > Bake Action... with following settings:
    image.png
**System Information** Operating system: windows 10 Graphics card: gforce 1060 6gb **Blender Version** Broken 2.92 alpha Broken 2.83 Worked: likely never **Short description of error** I have a row of bones, I add the curve modifier, I make an animation with that modifier on, I bake the animation of the bones to be able to send it to unreal or unity and the animation breaks completely **Exact steps for others to reproduce the error** [CurveBreackExample.blend](https://archive.blender.org/developer/F9179943/CurveBreackExample.blend) - Open file - inspect wrong bake of bone action - to reproduce: - go to object mode - select `SkeletonBase` object - go to pose mode (all bones should be selected) - Pose > Animation > Bake Action... with following settings: ![image.png](https://archive.blender.org/developer/F9180025/image.png)
Author

Added subscriber: @GabrielAntonioDelacruz

Added subscriber: @GabrielAntonioDelacruz

Added subscriber: @iss

Added subscriber: @iss

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'

Please upload simple .blend file that demonstrates this issue.

Please upload simple .blend file that demonstrates this issue.
Author
[CurveBreackExample.rar](https://archive.blender.org/developer/F8769781/CurveBreackExample.rar)

Changed status from 'Needs User Info' to: 'Needs Developer To Reproduce'

Changed status from 'Needs User Info' to: 'Needs Developer To Reproduce'
Member

Changed status from 'Needs Developer To Reproduce' to: 'Needs Triage'

Changed status from 'Needs Developer To Reproduce' to: 'Needs Triage'
Philipp Oeser changed title from Baking animation of bones affected by a curve to Baking animation of bones affected by a curve (spline IK) is wrong 2020-11-03 10:51:20 +01:00
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Sybren A. Stüvel self-assigned this 2020-11-05 15:45:58 +01:00

I think there are two issues at work here:

  1. The Bake Action code doesn't do visual keying correctly (it seems to be using the wrong matrix math).
  2. There is an issue with the Spline IK causing bones to become the wrong scaling. This is handled already in #81704 (Spline IK "Bone Original" Y-scale Causes Scaling).

For this task I'll focus on the first item, as the 2nd is already handled somewhere else.

I think there are two issues at work here: 1. The Bake Action code doesn't do visual keying correctly (it seems to be using the wrong matrix math). 2. There is an issue with the Spline IK causing bones to become the wrong scaling. This is handled already in #81704 (Spline IK "Bone Original" Y-scale Causes Scaling). For this task I'll focus on the first item, as the 2nd is already handled somewhere else.

Added subscriber: @Josephbburg

Added subscriber: @Josephbburg

It looks like the visual keying issues I thought were there, aren't. This seems to be caused by the Spline IK constraint somehow. @Josephbburg do you have any insight here?

Here is a simplified file that I made. It has no animation, just a scale on the root bone and a Spline IK on the tip bone.

#79670-spline-scaled-nonanimated.blend

To reproduce:

  • Ensure all bones are selected; this gives you the "Before" image.
  • Press {key Ctrl A} and choose "Apply Visual Transform to Pose".
  • Disable the Spline IK constraint; this gives you the "After" image.

image.png

I've expanded my "Copy Visual Transform" add-on to aid in debugging this. It has a button "Bake Selected Bones" and a nice display of the bone matrices .matrix and .matrix_basis.

image.png

Even with D9244: Fix #81704 applied, there still seems to be a slight scaling error creeping in. And then at Bone.008 all of a sudden things explode.

It looks like the visual keying issues I thought were there, aren't. This seems to be caused by the Spline IK constraint somehow. @Josephbburg do you have any insight here? Here is a simplified file that I made. It has no animation, just a scale on the root bone and a Spline IK on the tip bone. [#79670-spline-scaled-nonanimated.blend](https://archive.blender.org/developer/F9210676/T79670-spline-scaled-nonanimated.blend) To reproduce: - Ensure all bones are selected; this gives you the "Before" image. - Press {key Ctrl A} and choose "Apply Visual Transform to Pose". - Disable the Spline IK constraint; this gives you the "After" image. ![image.png](https://archive.blender.org/developer/F9210698/image.png) I've expanded my "[Copy Visual Transform](https://raw.githubusercontent.com/sybrenstuvel/random-blender-addons/main/copy_visual_transform.py)" add-on to aid in debugging this. It has a button "Bake Selected Bones" and a nice display of the bone matrices `.matrix` and `.matrix_basis`. ![image.png](https://archive.blender.org/developer/F9210725/image.png) Even with [D9244: Fix #81704](https://archive.blender.org/developer/D9244) applied, there still seems to be a slight scaling error creeping in. And then at `Bone.008` all of a sudden things explode.
Sybren A. Stüvel removed their assignment 2020-11-05 18:15:58 +01:00

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

Well, here's something interesting -- if you set the bones to use "ALIGNED" scale inheritance and THEN bake using the operator, then there seems to be no issue. This makes sense -- the Spline IK constraint handles the scaling components separately. Y is handled and then XZ is handled, and so "aligned" is the most correct way to bake the scale inheritance. I'm fairly certain this is the cause of the bug. The Y scale sets the length of the bone, which sets the next point on the curve that the constraint uses. Then the bone is rotated to point towards it (basically Damped Track) and scales along the local y axis until the tail reaches that point. So the situation is weird -- the input scale is not directly correlated with the output scale. In face, with sufficiently weird curves, you can get much shorter or longer bones than the y-scale should create. Here's a .blend that shows this problem:
#79670-spline-scaled-nonanimated_Bad.blend

It's a really difficult corner case, it's always weird when increasing the scale results in a shorter bone!

I haven't closely read the code of your addon, but I have a suspicion that it isn't factoring the parent's scale or scale inheritance mode in, at least not the same way the baking operator does, Weird behavior like scale explosion after a few bones is actually normal in my experience -- in fact, I've gotten this behavior in scripts that apply a rotation matrix to each bone in a chain one at a time (In my ChainTools addon, it's "SnapPoseBonesToCurve "). Even if the matrices don't contain any scale, and in fact, even when the matrices are decomposed and recomposed to remove scale, this will still occur. So I think all that is happening there is floating point error. In my experience, Python's values aren't very trustworthy past 3 decimal places. I always round them in my own scripts.

Finally, I don't see this as directly related to Y-Scale Mode bug, but even if it is --if there's still slight scale errors creeping in, it's probably just because the fix isn't perfect. In fact, the .blend file I just uploaded should reveal the error in my fix. I mean to solve it by a brute-force bisection search, but I've been too busy to look into it for the past few weeks 😭 . I don't think they're related, though, because it looks like the baking code is just interpreting scale inheritance incorrectly for this situation.

Well, here's something interesting -- if you set the bones to use "ALIGNED" scale inheritance and THEN bake using the operator, then there seems to be no issue. This makes sense -- the Spline IK constraint handles the scaling components separately. Y is handled and then XZ is handled, and so "aligned" is the most correct way to bake the scale inheritance. I'm fairly certain this is the cause of the bug. The Y scale sets the length of the bone, which sets the next point on the curve that the constraint uses. Then the bone is rotated to point towards it (basically Damped Track) and scales along the local y axis until the tail reaches that point. So the situation is weird -- the input scale is not directly correlated with the output scale. In face, with sufficiently weird curves, you can get much shorter or longer bones than the y-scale should create. Here's a .blend that shows this problem: [#79670-spline-scaled-nonanimated_Bad.blend](https://archive.blender.org/developer/F9214410/T79670-spline-scaled-nonanimated_Bad.blend) It's a really difficult corner case, it's always weird when increasing the scale results in a shorter bone! I haven't closely read the code of your addon, but I have a suspicion that it isn't factoring the parent's scale or scale inheritance mode in, at least not the same way the baking operator does, Weird behavior like scale explosion after a few bones is actually normal in my experience -- in fact, I've gotten this behavior in scripts that apply a rotation matrix to each bone in a chain one at a time (In my ChainTools addon, it's "[SnapPoseBonesToCurve ](https://gitlab.com/josephbburg/blender-chaintools/-/blob/development/ops_poseBone.py#L139)"). Even if the matrices don't contain any scale, and in fact, even when the matrices are decomposed and recomposed to remove scale, this will still occur. So I think all that is happening there is floating point error. In my experience, Python's values aren't very trustworthy past 3 decimal places. I always round them in my own scripts. Finally, I don't see this as directly related to Y-Scale Mode bug, but even if it is --if there's still slight scale errors creeping in, it's probably just because the fix isn't perfect. In fact, the .blend file I just uploaded should reveal the error in my fix. I mean to solve it by a brute-force bisection search, but I've been too busy to look into it for the past few weeks 😭 . I don't think they're related, though, because it looks like the baking code is just interpreting scale inheritance incorrectly for this situation.

Added subscriber: @Yad

Added subscriber: @Yad
Philipp Oeser removed the
Interest
Animation & Rigging
label 2023-02-09 14:36:11 +01:00

Hey guys, I have a similar issue when baking this huge chain of bones (193 bones + 192 bones) that were attached to 2 curves with spline IK . It seems that the end of the the first chain of bones is inaccurate after bake and does not stay put where it should. It is correct before the bake.

I attached the blend file.

I have 2 curves and 2 armatures. The curves share 1 of the many hooks in the middle.

Here are the settings for the last bone of each of the armature. It still does it if I change the Y Scale Mode to none.
image

Bake settings:
image

Before bake at frame 350 :
image

After bake:
image

I don't know if there is a work around. I am currently editing the final bake to make it align (not ideal 👎 ).

Hey guys, I have a similar issue when baking this huge chain of bones (193 bones + 192 bones) that were attached to 2 curves with spline IK . It seems that the end of the the first chain of bones is inaccurate after bake and does not stay put where it should. It is correct before the bake. I attached the blend file. I have 2 curves and 2 armatures. The curves share 1 of the many hooks in the middle. Here are the settings for the last bone of each of the armature. It still does it if I change the Y Scale Mode to none. ![image](/attachments/b8343fb6-9688-491d-8fe3-aa581b05a71c) Bake settings: ![image](/attachments/1c736b11-68c3-4137-adec-dd10de7d3020) Before bake at frame 350 : ![image](/attachments/ab79391b-dc08-4880-b7cb-b43dfc185469) After bake: ![image](/attachments/ea0a5586-1c65-4479-aa29-5c3872c7e737) I don't know if there is a work around. I am currently editing the final bake to make it align (not ideal 👎 ).

@Josephbburg wrote:

Well, here's something interesting -- if you set the bones to use "ALIGNED" scale inheritance and THEN bake using the operator, then there seems to be no issue.

Have you tried this, @Alin-Blindu ? Would it be a suitable workaround for you?

@Josephbburg wrote: > Well, here's something interesting -- if you set the bones to use "ALIGNED" scale inheritance and THEN bake using the operator, then there seems to be no issue. Have you tried this, @Alin-Blindu ? Would it be a suitable workaround for you?

Hey @dr.sybren I tried that on all of the bones and I am getting the same result.
image

Any other ideas?

Hey @dr.sybren I tried that on all of the bones and I am getting the same result. ![image](/attachments/813d3a06-1be7-45d4-9a99-b1df151c3f4f) Any other ideas?
1.5 MiB
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
8 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#79670
No description provided.