Can't create shape keys

I was following some youtube tutorials to make corrective shape keys, but my rig is acting too weird.
That’s the process i followed:

  • Select the bone and move;
  • Go to object mode, create a new shape key, set it to 1 and sculpt
  • Create a driver and set like this
    image

But isn’t working. When i go back to neutral pose, the shape key don’t respect it. It’s like the value is always 1, even when the driver curve shows the opposite.
image

That driver expression seems a bit weird specifically “**” which is strange to need to multiply twice like that or is probably a typo… Anyway try this simpler expression var * multiplier (the value depends on how much the driving bone moves for example here is moving too little, therefore I would guess is something about 0.02 m or 2 cm of transformation value or so depending in that you have to multiply that like this var * 50 to get the shape slider up to 1.0)

1 Like

I’m assuming that the - ** - is a typo. In python the - ** - is exponential operator. So basically the result of (var/.03)*var is being squared. Then you have to consider the order of operations and I’m thinking exponents are evaluated first (a bit rusty on this). So I’m thinking the end result of that expression is
var^2 * (var/.03)

Randy

2 Likes

Do you know a source for learning about complex driver math functions and stuff and how to use it, maybe old tutorials?

No, not really. I learned by trial and error, helping others with problems and solving their problems here, on this forum, was one way. I was an active blender user up to 2.76, then I left, and returned about a year ago. In the blender 2.5-2.76 days the dev working on the animation system had a blog where he explained the changes and how things worked.

Basically, the Expression field is for python code. So any expression you write there is bound by how python does things. For basic math stuff, you don’t need to know python, but at the same time you can’t put in var ^ 2 and expect a correct output. I would expect an error message.

You can also use a pydriver here too. That will call python code that you write, and return the result. This allows for If-Then-Else type of driver.

If you wanna know more, just ask…

Randy

1 Like

Ok sure if I have any doubts I would send you a message to ask for a little help, thanks :+1:t3:.

Edit: oh for example how should be driven a scale input into a loc input for example: the scale input is at 1.0 in the z axis of the bone controller, but I want to drive another bone in its x axis at a value specifically from 0 to 0.1 m, but the problem that I found I don’t know how to make the driver expression to interpret the value as 0 first (instead is at 1.0 m when activated) and then by either scaling negative or positive values of 0.500 on z axis then it drives the bone to 0.1 m, and tell where to invert the value in that expression sentence (“-” to subtract or nothing which is interpret by default as sum).

Additionally do you how to invert a driver (like does the generator modifier in drivers editor by editing the polynomial input by making it negative to flip the curve) but within the scripted expression itself…

I want to know later if you have time to explain those if and else and how to use them and specifically “=< or =>” and min max setup for more than two values (sometimes I may want something like 0 then 0.5 then 1 for example) which I have seen in the blender stack exchange forum a lot but they don’t explain a lot rather than just answer the specific question…

Well, we might be hi-jacking this thread, but maybe @Carolina_Nicolletti will find this info helpful in solving their problem, as well as anyone else who stumbles upon this…

Can you come up with a math formula that will give you that result? Input would be 0.5 to 1.5 (scale), and output would be 0 to 0.1 (location). I can’t, but I suck at math.

Instead of using an expression type driver, use an averaged value type and create a curve to give you the results you want.

The x-axis is the input value, y-axis is output value. If the scale (x-axis) is 0.5 or 1.5, the output will be 0.1

scale_loc_driver_example.blend (845.5 KB)

I wouldn’t do it with a scripted expression, I’d use a custom curve to do it. A curve with a point at (0, 0) and a point at (1, 1) would be a positive output. Points at (0, 0) and (1, -1) would give you a negative output.

To handle this -

I assume you mean that as an output? Here again, a custom curve does the job.

Not the values you suggested, but open the file and move the Master bone and see what happens.

constant_step_driver_example.blend (865.2 KB)

We can talk python drivers later…

Randy

1 Like

So pydrivers work like this:

py_driver_example.blend (897.3 KB)

When you first open the file, if auto-exec of scripts is turned off, blender’s default setting, you will be prompted to allow execution of scripts. Allow execution of scripts. Then click on the play icon in the text editor. Then click the Update Dependencies button in the Driver Editor. (If auto-exec is enabled, it should just work without anything I just mentioned)

With suzanne selected, there is a custom prop in the transforms panel. If the prop is set to 0, the cube’s x-axis loc drives suzanne’s z loc. If the prop is set to 1, the icosphere’s y-axis loc drives suzanne’s z loc.

In the drivers editor, I define 3 variables. One for the cube’s x-loc, one for the icosphere’s y-loc, and one for the custom prop on suzanne. The expression field is

mix(obj2, obj3, mix)

which passes those variables to the python script. The script checks the mix value and returns a value based on what the mix value is (0 or 1).

Randy

1 Like