Corrective shape keys driven by bone rotation

Hello BA. I need some help. I want to apply corrective shape key to mesh that working in specific range of bone rotation. How to do this? I need to set up driver to start applying shape key from say 90 degrees of bone rotation and finished when bone is in 120 degrees.
I want:
90 degrees x axis = 0 shapekey
120 degrees x axis = 1 shape key

I have installed driver constraints addon it has options to set up limits of driver and shapekey, but still didn’t figured out how it all works. Changing limits doesn’t change anything for me. :frowning:

Sorry for bad english and thank you in advance.

The simplest way is creating a Sum Values type driver that uses raw rotation values from the bone. This driver needs a Transform Channel variable that refers to one of the X,Y,Z rotation axes of the bone in Local Space:
driverRawRotation1

Then you can use the graph curve to make the driver put out the values you want within that specific angle interval.
The horizontal axis of the driver curve is the “preliminary” driver value (from the sum of variables or the scripted expression etc.), and the vertical axis is the actual value the driver puts on your shape key.
That “Sum Values” type means the driver will sum the values of all variables (in this case just one variable, the Transform Channel).
That variable happens to produce the bone rotation in radians (instead of degrees, so you’ll have to convert those degree limits to radians). You’re going to place keyframes on the curve in order to map angles in radians with the values the shape key should have.
The curve should look like this:
driverRawRotation2

Both keyframes have interpolation set to Linear.
The frame of the first keyframe is 1.5708 (90 degrees, in radians), and the value is 0 (zero, the value the shapekey should have at that moment.
The frame of the second keyframe is 2.0944 (120 degrees, in radians), and the value is 1.
The channel extrapolation (Shift + E) is set to Constant Extrapolation.

So when the bone rotates on the X axis from 1.5708 to 2.0944, the shapekey will go from 0 to 1.


The problem with this type of driver is that it only works if you can guarantee that the bone will only rotate on the axis you care about. The moment the bone rotates on more than one axis then the values can flip, making your shape keys pop on and off. Here I’m driving the Z coordinate of the X, Y and Z letters with the same rotation axes from the bone, one axis for each letter. See how they pop as you roll the bone (this would happen with your shapekeys):
driverRawRotation3

I’m not fully certain why it happens, I think it’s due to how the math in the Transform Channel variable works out to use the shortest rotation possible, since there are infinite rotations that look the same.

So if you need to drive shape keys from bones that need to rotate in more than one direction (like an upper-arm or thigh bone, which are socket-type joints that rotate in all directions, plus roll around their aim direction), you need to use the dot product between two bones’ aim directions, like this:
https://blender.stackexchange.com/questions/112657/how-to-drive-shape-keys-based-on-the-angle-between-two-bones
This way avoids flipping for socket-type joints (a bone that rotates in more than one axis).

1 Like

Thank you very much. You helped me a lot!