Skip to main content
Updated content to reflect changes in Blender.
Source Link
R. Navega
  • 536
  • 3
  • 13

This answer was written for Blender 2.79 and 2.80. The latest versions of Blender from 2.82 and above (like 3.0, 4.0 etc) have a "Swing" driver type that can be used for this: https://docs.blender.org/manual/en/latest/animation/drivers/drivers_panel.html#rotation-channel-modes

So the original text below is obsolete as it was written before this new driver mode existed. It's kept for historical purposes anyway.

Original answer:


For an ultra-fast driver for corrective shape keys based on the angle between two bones, you can use this one:

##Notes:

Notes:

For an ultra-fast driver for corrective shape keys based on the angle between two bones, you can use this one:

##Notes:

This answer was written for Blender 2.79 and 2.80. The latest versions of Blender from 2.82 and above (like 3.0, 4.0 etc) have a "Swing" driver type that can be used for this: https://docs.blender.org/manual/en/latest/animation/drivers/drivers_panel.html#rotation-channel-modes

So the original text below is obsolete as it was written before this new driver mode existed. It's kept for historical purposes anyway.

Original answer:


For an ultra-fast driver for corrective shape keys based on the angle between two bones, you can use this one:

Notes:

Added note about senoidal speed vs linear speed
Source Link
R. Navega
  • 536
  • 3
  • 13

Instead of "My Bone", use the name of the bone whose index you want to find, then press Enter to see the result. Do this once for each bone so you'll have two numbers, like 12 and 103 for example. Put them in the expression (in any order), inside the poseBoneposeBones brackets:

 

###Notes##Notes:

  • The two bones used in the expression should not be animated in scale (be it their own or inherited scale from their parents), they should only be animated in position and rotation. This means that they need to have a scale of exactly 1 in all axes, for the entire animation, otherwise this will mess with the speed of the driver because it affects the length of the matrix.col[1] vector.
  • If you need to animate them in scale, simply add a child bone to them and animate the scale of the child and deform the mesh with that child bone, not the parent.
  • You can adjust the timing and speed of this driver by playing with the driver graph curve, like using easing or bezier handles. 
  • For example, when used with shape keys, you can make the graph minimum be zero and maximum be 1 (click to enlarge): 
    Driver graph curve with Linear keys
  • The natural rate of change of this driver is senoidal because of the dot product that it uses in the expression. If you happen to need linear speed, adjust the bézier handles of the curve in this way to keep the rate of change constant (click to enlarge):
    enter image description here
  • The poseBones variable in the driver is referencing the .pose.bones property of the armature object (like bpy.data.objects("Armature")) and not the armature data (like bpy.data.armatures("Armature")). That .pose property exists in objects only.

Instead of "My Bone", use the name of the bone whose index you want to find, then press Enter to see the result. Do this once for each bone so you'll have two numbers, like 12 and 103 for example. Put them in the expression (in any order), inside the poseBone brackets:

###Notes:

  • The two bones used in the expression should not be animated in scale (be it their own or inherited scale from their parents), they should only be animated in position and rotation. This means that they need to have a scale of exactly 1 in all axes, for the entire animation, otherwise this will mess with the speed of the driver because it affects the length of the matrix.col[1] vector.
  • If you need to animate them in scale, simply add a child bone to them and animate the scale of the child and deform the mesh with that child bone, not the parent.
  • You can adjust the timing and speed of this driver by playing with the driver graph curve, like using easing or bezier handles. For example, when used with shape keys, you can make the graph minimum be zero and maximum be 1 (click to enlarge): Driver graph curve with Linear keys
  • The poseBones variable in the driver is referencing the .pose.bones property of the armature object (like bpy.data.objects("Armature")) and not the armature data (like bpy.data.armatures("Armature")). That .pose property exists in objects only.

Instead of "My Bone", use the name of the bone whose index you want to find, then press Enter to see the result. Do this once for each bone so you'll have two numbers, like 12 and 103 for example. Put them in the expression (in any order), inside the poseBones brackets:

 

##Notes:

  • The two bones used in the expression should not be animated in scale (be it their own or inherited scale from their parents), they should only be animated in position and rotation. This means that they need to have a scale of exactly 1 in all axes, for the entire animation, otherwise this will mess with the speed of the driver because it affects the length of the matrix.col[1] vector.
  • If you need to animate them in scale, simply add a child bone to them and animate the scale of the child and deform the mesh with that child bone, not the parent.
  • You can adjust the timing and speed of this driver by playing with the driver graph curve, like using easing or bezier handles. 
  • For example, when used with shape keys, you can make the graph minimum be zero and maximum be 1 (click to enlarge): 
    Driver graph curve with Linear keys
  • The natural rate of change of this driver is senoidal because of the dot product that it uses in the expression. If you happen to need linear speed, adjust the bézier handles of the curve in this way to keep the rate of change constant (click to enlarge):
    enter image description here
  • The poseBones variable in the driver is referencing the .pose.bones property of the armature object (like bpy.data.objects("Armature")) and not the armature data (like bpy.data.armatures("Armature")). That .pose property exists in objects only.
deleted 3 characters in body
Source Link
R. Navega
  • 536
  • 3
  • 13

(In order for this expression to work you need to enable the Auto Run Python Scripts setting in Blender. On 2.80 it's in Preferences -> Save & Load -> Auto Run Python Scripts and on 2.79 it's in User Preferences -> File -> Auto Run Python Scripts.)

This expression uses It's thethe dot product of the bones' aim vectors, a mechanism known as a "pose reader", used with pose space deformation (PSD).
As the bones rotate during animation or posing, the driver will output a value in the range [-1, +1], going from -1 when the bones point in opposite directions, up to 0 when they become perpendicular, up to +1 when they point in the same direction.

  • In order for this driver to work, you need to enable the Auto Run Python Scripts preference:
  • Blender 2.80+: Edit -> Preferences -> Save & Load -> Auto Run Python Scripts.
  • Blender 2.79: File -> User Preferences -> File -> Auto Run Python Scripts
  • The two bones used in the expression should not be animated in scale (be it their own or inherited scale from their parents), they should only be animated in position and rotation. This means that they need to have a scale of exactly 1 in all axes, for the entire animation, otherwise this will mess with the speed of the driver because it affects the length of the matrix.col[1] vector.
  • If you need to animate them in scale, simply add a child bone to them and animate the scale of the child and deform the mesh with that child bone, not the parent.
  • You can adjust the timing and speed of this driver by playing with the driver graph curve, like using easing or bezier handles. For example, when used with shape keys, you can make the graph minimum be zero and maximum be 1 (click to enlarge): Driver graph curve with Linear keys
  • The poseBones variable in the driver is referencing the .pose.bones property of the armature object (like bpy.data.objects("Armature")) and not the armature data (like bpy.data.armatures("Armature")). That .pose property exists in objects only.

It's the dot product of the bones' aim vectors, a mechanism known as a "pose reader", used with pose space deformation (PSD).
As the bones rotate during animation or posing, the driver will output a value in the range [-1, +1], going from -1 when the bones point in opposite directions, up to 0 when they become perpendicular, up to +1 when they point in the same direction.

  • In order for this driver to work, you need to enable the Auto Run Python Scripts preference:
  • Blender 2.80+: Edit -> Preferences -> Save & Load -> Auto Run Python Scripts.
  • Blender 2.79: File -> User Preferences -> File -> Auto Run Python Scripts
  • The two bones used in the expression should not be animated in scale (be it their own or inherited scale from their parents), they should only be animated in position and rotation. This means that they need to have a scale of exactly 1 in all axes, for the entire animation, otherwise this will mess with the speed of the driver because it affects the length of the matrix.col[1] vector.
  • If you need to animate them in scale, simply add a child bone to them and animate the scale of the child and deform the mesh with that child bone, not the parent.
  • You can adjust the timing and speed of this driver by playing with the driver graph curve, like using easing or bezier handles. For example, when used with shape keys, you can make the graph minimum be zero and maximum be 1 (click to enlarge): Driver graph curve with Linear keys
  • The poseBones variable in the driver is referencing the .pose.bones property of the armature object (like bpy.data.objects("Armature")) and not the armature data (like bpy.data.armatures("Armature")). That .pose property exists in objects only.

(In order for this expression to work you need to enable the Auto Run Python Scripts setting in Blender. On 2.80 it's in Preferences -> Save & Load -> Auto Run Python Scripts and on 2.79 it's in User Preferences -> File -> Auto Run Python Scripts.)

This expression uses the dot product of the bones' aim vectors, a mechanism known as a "pose reader", used with pose space deformation (PSD).
As the bones rotate during animation or posing, the driver will output a value in the range [-1, +1], going from -1 when the bones point in opposite directions, up to 0 when they become perpendicular, up to +1 when they point in the same direction.

  • The two bones used in the expression should not be animated in scale (be it their own or inherited scale from their parents), they should only be animated in position and rotation. This means that they need to have a scale of exactly 1 in all axes, for the entire animation, otherwise this will mess with the speed of the driver because it affects the length of the matrix.col[1] vector.
  • If you need to animate them in scale, simply add a child bone to them and animate the scale of the child and deform the mesh with that child bone, not the parent.
  • You can adjust the timing and speed of this driver by playing with the driver graph curve, like using easing or bezier handles. For example, when used with shape keys, you can make the graph minimum be zero and maximum be 1 (click to enlarge): Driver graph curve with Linear keys
  • The poseBones variable in the driver is referencing the .pose.bones property of the armature object (like bpy.data.objects("Armature")) and not the armature data (like bpy.data.armatures("Armature")). That .pose property exists in objects only.
Rewritten some parts for clarity. Added text covering the 2.7x and 2.8x differences.
Source Link
R. Navega
  • 536
  • 3
  • 13
Loading
Rewritten some parts for clarity. Added text covering the 2.7x and 2.8x differences.
Source Link
R. Navega
  • 536
  • 3
  • 13
Loading
added 146 characters in body
Source Link
R. Navega
  • 536
  • 3
  • 13
Loading
Added information
Source Link
R. Navega
  • 536
  • 3
  • 13
Loading
Source Link
R. Navega
  • 536
  • 3
  • 13
Loading