4
$\begingroup$

Sorry for the noise... My previous question was answered, and I've fixed what I was doing wrong; but only so far as to allow me to phrase a new question, as my original problem still exists. :/

I am trying to apply a driver to the Y Location of a mapping node in a material definition:

My mapping node

Note that I have previously keyframed this Y value successfully, but now I want to use a driver so that I can drive this from a complex animation that's on a different object. I have deleted all its keyframes.

The driver tracks the value of a shape key:

My driver setup

However, when I scrub through the timeline, the value of the driver (in the bottom field of the driver panel) doesn't update. Instead, it shows the key shape's value for the frame that was current when the project loaded. I can prove this by saving it with the playhead in various places.

If I apply the same shape key to a driver that affects, say, an object's X scale, it works fine, updating as I scrub.

In my simple mind, I'm directing a single floating point value to a single floating point value, so I don't know why it's not working. Maybe I'm wrong?

The scripted expression simply maps the key shape's range (0.0 to 0.8) onto the range for Y Location that I was using when I keyframed it (-14.0 to 0.0).

Is there something I'm missing?

$\endgroup$
2
  • $\begingroup$ Just a comment. No suggestions. In the past months ago I have experienced similar problems to yours. Today I tried to do something very similar to your image above and I could not create the same Blender defect experience. It works for me. Blender 2.78. $\endgroup$ Commented Apr 20, 2017 at 3:30
  • $\begingroup$ I'm using 2.78c. $\endgroup$ Commented Apr 20, 2017 at 14:18

2 Answers 2

7
$\begingroup$

Unfortunately, not all drivers are created equal - especially when it comes to driving values in a material.... some drivers simply don't trigger their updates to propagate correctly on change of value while others do (a bug, I presume).

I've found that the most reliable source for drivers seems to be the object Custom Properties and you can use that to simultaneously drive both the material Mapping value and the shape key value - rather than using the Key to drive the material. This way you only need to adjust the Custom Property and both values (the material and the shape key) will change - rather than changing the Shape Key.

First, create the custom property by selecting Object in the Properties side panel, scrolling down to Custom Properties and clicking 'Add'.

add property

Edit the property as desired (since you want it to drive a shape key you probably want it to have Min/Max set to the default 0.0 and 1.0) and give it a suitable name (I've left mine as 'prop').

Go to the Material and add the driver as normal (right-click the Location in the Mapping node and select Add Single Driver). Do the same with the Shape Key value.

Go to the Graph editor and select Drivers. Locate your drivers and set the type to Averaged Value, the default variable ('var') to Single Property, set it to your object and enter the Path as '["prop"]' (where 'prop' is the name of the property you created). Click Update Dependencies for good measure. Do this for both of your drivers.

driver

Now you should find that changing the Custom Property on the object should update both values. Custom Properties can be keyframed just like anything else.

One advantage of using Custom Properties is that you can put all of your 'controls' in one place - rather than having to hunt out the different panels for, say, Shape Keys, etc.

NOTE: If the driver only needs to use a value from a property or channel - rather than perform a calculation - then using Averaged Value means that you don't need to enable 'Scripting' in the Blender User Preferences. However, if you do need to use Scripted Values then you'll need to enable scripting by enabling Auto Execution in the File tab of the User Preferences.

$\endgroup$
6
  • $\begingroup$ Thanks! Working on this... I will need to use scripting (which is auto-run enabled) as I have different scale factors and constants for different applications of the animation. I'll let you know if this works for me. $\endgroup$ Commented Apr 19, 2017 at 20:59
  • $\begingroup$ Grrr... I'm trying to copy the keyframes from the shape key animation to my new empty-with-a-custom-property, and it's not doing it right. My animation is smooth, bezier, with range 0.0 to about 0.8. But when I use the Copy Keyframes action and Paste Keyframes action to copy the trace to my custom property, it looks in the graph editor like a square wave with integer values of 0 and 1... but the actual keyframe markers are in the right places, with the original Bezier handles! Why is the graph integerized? My property has a range 0.000 to 1.000, which looks like floating point to me...! $\endgroup$ Commented Apr 19, 2017 at 21:06
  • $\begingroup$ @DanBennett Properties can be different 'types' depending on what value you set it to. If you've typed an integer value into the Proptety Value then it will be assuming it's an integer. Click Edit and enter the Property Value as 0.0 and it should be back as a float. $\endgroup$ Commented Apr 19, 2017 at 21:13
  • 1
    $\begingroup$ Well knock me down with a wet kipper! That fixed that problem! Not intuitive...! Thanks! $\endgroup$ Commented Apr 19, 2017 at 21:18
  • $\begingroup$ Wonderful - thanks! My material now animates properly! $\endgroup$ Commented Apr 19, 2017 at 21:25
0
$\begingroup$

This seems to be a big bug... I can only drive material properties after randomly adding and removing geometry drivers to the same object. I see similar behavior in 2.77 and 2.78. See here for more details:

https://www.questarter.com/q/how-to-get-a-material-property-driver-to-update-properly-2-78-16_70784.html

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .