In the Drivers window: Select the Shape Key Value Driver. Press N to bring up the Properties shelf. In the Drivers panel, select Averaged Value for the Type. In the Object/Bone field, select Armature. And in the Bone field, select the bone which you want to assign the shape key to. It took a while but on Blender Git master as well as the branched Blender 2.80 code there is now the support for CUDA 10.0 for Cycles and NVIDIA Turing GPU support. This support comes after Blender 2.80 reached its beta period days ago. The Turing-enabled Blender builds can be found via the daily updated beta builds.
There is one moment in node tree, created to separate the sides of the planet model by “day” and “night” – when the position of light source changes its new coordinates every time needs to re-specify manually in Value nodes. It is very inconvenient while setting the scene. To eliminate this fault Blender “drivers” system can be used.
Lets make a simple scene showing the separation of the planet sides. Create a planet (sphere). The light source (plane) locate at 5,0,0. Create a material with “day” and “night” separation, append it to planet.
Simplify nodes tree packing what we do not need during setup into the groups.
- Select the desired nodes
- ctrl+G
There are only Value nodes with the coordinates of the light source outside groups. We will setup drivers to them.
Drivers – a Blender mechanism that uses properties, numbers, transformations, and scripts, to control the values of properties. In simple – drivers proceed dependences some object properties from properties of other objects. In this case we need to associate values from Value nodes in planet material with lighting plane coordinates.
To install driver to the X lighting source coordinate Value node:
![Drivers Panel Blender 3d Drivers Panel Blender 3d](/uploads/1/2/6/2/126227572/186654152.png)
- Click the right mouse button on the numerical value of Value node for X coordinate
- Select Add Driver
The value will painted in purple.
- Open the Graph Editor
- In its menu set Mode to Drivers
If node with driver is selected, the Graph Editor displays the name and path of the controlled value, curve and Drivers tab in the N-bar.
Pay attention to Drivers tab. First we need to configure driver type, regulated with Type parameter. Driver type is a formula that calculates driver output value. There are several variants:
- Maximum Value
- Minimum Value
- Scripted Expression – output value calculates by the expression on the scripting language
- Sum Values
- Average Values
These formulas, except Scripted Expression, are needed in order to handle multiple input values by driver. For example, if single object’s position depends on the positions of several other objects. Through a driver that handles multiple input location values, one result can be calculated. A Scripted Expression type you can set to get the output values from scripting language Pithon – this type is used, if other types are not enough.
In our case, we have one input value – X coordinate of the light source. Therefore, we can choose any type of driver, except Scripted Expression. For example – Sum Values. The sum of single number always equal to the same number.
- In Graph Editor
- In N-panel
- Drivers tab
- set Type to Sum Values
- Drivers tab
- In N-panel
Next, pay attention to created by default variable named “var”. This variable is the actual input value, which handles by driver. It also has a type:
- Distance – the distance between two objects
- Rotation Difference – the difference between the rotation angles of two objects
- Transform Channel – location data of the object
- Single Property – value of any object parameter, defined by the scripting language
All types, except Single Property, are used to obtain values that required more often. Like driver type, Single Property can be used to get any value of the object using the Pithon language. In our case we need to get the X coordinate of the light source. Therefore, we select the Transform Channel type.
In the Object/Bone field specify the object – the source of the input value. In our case – a light plane. It is necessary to specify the desired type of coordinate:
- In Graph Editor
- In N-panel
- Drivers tab
- “var” variable
- Set Type to Transform Channel
- In the Object/Bone field specify the light plane
- Set Type to X Location
- click the Update Dependencies – upgrade the relationship, ie, apply the specified values
- “var” variable
- Drivers tab
- In N-panel
Driver that connects the X coordinate of the light source and the Value node for this coordinate in the planet node tree is created and configured. Now if we try to move the light plane by its X coordinate from different sides of the planet, we can see that “day” and “night” textures changes their places.
In the same way we need to create and configure the two other drivers for the two remaining coordinates.
- Click the right mouse button on the numerical value of Value node for Y coordinate
- Add Driver
- Select node
- In Graph Editor
- In Drivers tab
- set Type to Sum Values
- For “var” variable
- set Type to Transform Channel
- In the Object/Bone field specify the light plane
- set Type to Y Location
- Press the Update Dependencies
- In Drivers tab
- In Graph Editor
- Click the right mouse button on the numerical value of Value node for Z coordinate
- Add Driver
- Select node
- In Graph Editor
- In Drivers tab
- set Type to Sum Values
- For “var” variable
- set Type to Transform Channel
- In the Object/Bone field specify the light plane
- set Type to Z Location
- Press the Update Dependencies
- In Drivers tab
- In Graph Editor
All three drivers for three coordinates of the light source are configured. Now we can move the light plane to any place – “day” and “night” textures of the planet always will be mapped correctly.
Simple Drivers can be configured from the pop-over that appears when adding a new Driver.
When adding multiple Drivers or for more advanced configurations,it is useful to have open the Drivers Editor.
Transform Driver¶
Control a property with an object’s transform.In this example, the Y rotation of Object 2 will be driven by the X position of Object 1.
Starting from a simple setup with two objects:
- Add a Driver to the Rotation Y property of the second object via the context menu or with Ctrl-D.
- Open the Drivers Editor and select the Y Euler Rotation property in the channels region.
- Open the Sidebar region and select the Drivers tab.
- Configure the driver to be the Averaged Value of a Transform Channel of the first object.
- Experiment with moving the first object and notice how it affects the Y rotation of the second object.
Scripted Expression - Orbit a Point¶
Orbit an object’s position around a point with a custom Scripted Expression.The object’s position will change when scrubbing the timeline.
Using trigonometry, circular motion can be defined in 2D using the sinus and cosine functions.(See Unit Circle.)
In this example, the current frame is used as the variable that induces the motion.
frame
is a Simple Expression that corresponds tobpy.context.scene.frame_current
.- Add a driver to the X Location property.
- Set the Driver Type to Scripted Expression.
- Add the expression
0+(sin(frame/8)*4)
, where:frame/8
: is the current frame of the animation, divided by 8 to slow the orbit down.(sin()*4)
: multiplies the result ofsin(frame/8)
by 4 for a bigger circle.0+
: is used to control the offset to the orbit center point.
- Add a driver to the Y Location property with the expression
0+(cos(frame/8)*4)
. - Scrub the timeline to see the effect.Experiment with the variables to control the size and center of the orbit.
Custom Function - Square Value¶
Create a custom function to get the square of a value (i.e. value2).Adding the function to the Driver Namespace allows it to be used from driver expressions.
The Driver Namespace has a list of built-in functions for use in driver expressions,as well as constants such as π and e.These can be inspected via the Python Console:
To add a new function to the Driver Namespace, the function itself needs to be implementedand then added to the
bpy.app.driver_namespace
.- Add the following to the Text Editor inside Blender and press Run Script.
- Add a driver with a Scripted Expression such as
square(frame)
. - Observe the effect when scrubbing the timeline.
There are more custom function examples available in Blender’s Text EditorTemplates ‣ Python ‣ Driver Functions.
Since Simple Expressions cannot accesscustom functions, using them only makes sense for complex computations.
Shape Key Drivers¶
Improved Mesh Deformation¶
Fix intersection problems that happen when using armatures and weight painting, especially at joints.Shape keys can also be used to tweak and refine a rig, for example to suggest muscle formations.In this example, a shape key is used to improve the deformation at the elbow of a rudimentary arm.
Left: Skeletal mesh deformation without correction.Right: Corrective shape key applied
- Add a mesh (in this example, a cylinder with loop cuts).
- Add an armature with a chain of bones.
- Skin the mesh to the armature using weight painting.
(Note: to parent the mesh to the armature: select the mesh first,then the armature and use Ctrl-P to parent with auto weights.)
Experiment with posing the armature and observe the deformation at the joint.To fix intersection problems or angles that look unsatisfactory,you can associate a Shape Key with a pose.
- Pose the armature such that the problems are visible.Be sure to cover the extreme poses that you want to support for the rig.
- With the mesh selected, add a new Shape Key in addition to the Basis key.Properties ‣ Mesh tab ‣ Shape Keys
- In order to author the shape key on top of the armature deformation,enable both Edit Mode Display and Cage Editing in the armature modifier.Properties ‣ Modifiers tab ‣ Armature Modifier ‣ Header
- Enter Edit Mode and select the new shape key in the properties panel.Adjust the vertices as desired.Select the Basis key to toggle between the original mesh and your edits.(Note: be careful to apply edits only to your shape and not tothe original mesh or other existing keys.)
Once you are satisfied with how the deformation looks for the problematic pose,you’ll need to configure a driver to activate the shape smoothly when entering that position.
- Add a driver to the Value of the shape key you’ve created.
- Open the Drivers Editor and select the driver.
A simple way to configure the driver is with a direct correspondence ofthe value of a bone’s rotation channel to the shape key activation Value.This method has the disadvantage of relying on a single channel of a bone’srotation which might be insufficient to precisely express the conditionunder which the shape key should be activated.
- In the Drivers tab, select the Averaged Value of the rotation ofthe bone you’re posing.Understand the rotation axis that you’re interested in by enabling axes displayin the armature or by observing the bone’s transform values in the Properties.Select the rotation channel and set it to local, meaning, the bone’srotation value relative to its parent bone.
- Manually set points in the driver curve by selecting a handle anddragging it or inserting values in the F-Curve tab.The Y axis represents the shape key Value, which should go from 0.0 to 1.0.The X axis is usually the frame, but for this driver it represents the rotation value in radians.You can have more than two points in the curve and tweak the transitionswith the handles in the curve view (G to move).
- To verify that the driver behaves correctly, deselect the option toonly show drivers for selected objects. This way, you can pose the armatureand keep an eye on the driver.
This method requires an additional target or corrective bone, but itbetter expresses the spatial condition in 3D space of the bone that iscausing the problem.
- In armature Edit Mode, add a new bone extruded from Bone 1,in the position at which Bone 2 should have the shape key active.This type of bones usually follow a naming convention such as“TAR-” (target) or “COR-” (corrective).
- In the Drivers tab, select the Averaged Value of the rotational differencebetween the bone you’re rotating and the target bone.A rotational difference is the minimum angle between two objects in World Space.It is therefore important that the bones have the same root,so that the only thing affecting the angle between the bones is the rotation of one of them.When the deformation bone (Bone 2) reaches the target rotation (TAR-Bone 2)the rotational difference will be 0°.
- Manually adjust the driver curve handles so that the shape key Value(Y axis) is 1.0 when the rotational difference (X axis) is 0°.The Value should be 0.0 when the arm is extended, at which pointthe rotational difference should be around 90° or more (in radians).
- See the steps in Method 1 on how to adjust the curve handles andconfirm that the functionality is working. Pose the armature toverify that the ranges are correct.
Chained Relative Shape Keys¶
Activate different shape keys in succession.In this example, moving a single bone will activate first Key 1 and then Key 2.See also relative shape keys mix additively.
- Shape Keys
- Add two shape keys to a mesh, besides the Basis.
Key 1: top faces moved up by 1m |
Add an armature with a single bone to control the shape keys.The goal is to activate the keys in succession as this bone moves up.
As shown in the picture above, when the bone is halfway up, both Key 1 and Key 2 have an influence.It is a matter of preference if Key 1 should be at its maximum Value before Key 2 starts to become active,or how much they should overlap. This example shows a seamless blend.
For a seamless blend where there is overlap, Key 1 should have a Value of 0.0 when the boneis at the bottom and increase linearly to 1.0 until the bone is past the midpoint height.Key 2 should have a value of 0.0 before the midpoint height and then increase at the samerate than Key 1 until reaching Value 1.0 when the bone is at maximum height.
- Add a driver to the Value of Key 1 and Key 2.In the Drivers tab, configure both drivers to be the Averaged Value ofa variable with the bone’s Z location.
- Determine the range of the bone’s motion in the World Z axis by moving it up so that it isaligned with the top of the mesh when both keys are active. Here we will use [0.0 , 2.5].
- Configure the driver functions so that the Value of the shape keys (Y axis) is asdesired for the bone’s height (X axis).The driver functions should be linear, therefore, they can be defined analyticallywith a function of type (y = a + bx),where (a) is an offset in (y) and (b) is the slope.
- In the Modifiers tab, add a Generator of type Extended Polynomial for both drivers.
- Play with the values of (a) and (b) so that the curves go from [0.0 , 1.0]in the Y axis and from [0.0 , 2.5] in the X axis.The curves should overlap in the mid area of the X axis and they should have the same slope ((b)).Possible values are Key 1: (y = 0.0 + 0.6x) and Key 2: (y = -0.5 + 0.6x).Note that the functions go outside the range [0.0 , 1.0] for the shape keys’ Value,but that has no effect because Value is clamped in a Range in the Shape Keys panel.