3
$\begingroup$

I have an model with an armature. On several bones are custom properties which are used in drivers.
At the end, the model and the armature should be linked in another scene and the custom properties are used to control certain functions of the model.

My problem now is that I want to control a color of an material node by means of a custom property. For that I added the hex value of the color to the property to use this value in a corresponding driver which should set the color of the material node. But the variables in the driver only accept numeric values and hex is a string. Is there any other way to control a color in a linked object?

Blender 2.75, on Windows

$\endgroup$
8
  • $\begingroup$ Is your goal to change colors continuously on every frame? Is your goal to select between a limited set of colors, say 10 colors. Can you show your custom properties in a screen capture or python? $\endgroup$ – atomicbezierslinger Sep 3 '15 at 2:05
  • $\begingroup$ The colors should be set freely, a set is not enough. $\endgroup$ – George Miller Sep 3 '15 at 14:29
  • $\begingroup$ Can you provide an estimate of the number of colors? 5,10,15,800? The number of colors may impact how the python script is written. $\endgroup$ – atomicbezierslinger Sep 3 '15 at 15:35
  • $\begingroup$ Add your own function into driver space that converts hex to int - int('aabbcc',16) then use your function in the scripted expression. $\endgroup$ – sambler Sep 3 '15 at 16:07
  • $\begingroup$ AFAIK you need to drive the RGBA values individually. If you are into scripting you could set up a color vector property and drive each with each value. Othewise set up a custom property for each channel. $\endgroup$ – batFINGER Sep 3 '15 at 17:16
3
$\begingroup$

With current blender versions, you can create multi-dimensional custom property fields. These will look this:

You create them by setting the value on your custom property to this format:

[0.2, 0.4, 0.3]

Blender Multi-Dimensional Custom Property

Be sure to set your color value to the correct type, the default is "linear", for RGB values "gamma-corrected" is usually what you would want.

You can then draw this property anywhere in the blender UI, if you wish. This is a short breakdown on the naming conventions

Blender Drawing Color Property into Panel

If you want to use this to drive a material color on an object, so the color picker actually influences the color of a part of a model, you should set up a RGB-node in the Shader-Node-Tree (the Shader Editor).

Open the input field for the color and then add a driver to each color channel.

Blender Driving a Color Picker from the Input Values of a Custom Property

To access the channels as driver input variables, use the following pattern:

["NameOfCustomProperty"][NumberOfChannel]

or in an example

["color_ball"][0]

this would give the red channel.

["color_ball"][1]

this would give the green channel.

["color_ball"][2]

this would give the blue channel.

$\endgroup$
2
$\begingroup$

As you have found the Driver values that you can setup to use in your python expressions are limited to float values. Instead of setting a hex value you can setup three float values, one for red, one for blue and one for green.

Select the relevant bone you want to hold your colour settings and create three properties, for simplicity I will name then red, green and blue.

Add a driver to the colour swatch in your material (this can be used for either BI or cycles materials) and setup the driver to to get a single property from the rig and enter the path as pose.bones["ear.l"]["red"] - adjusting the bone name to suit. Repeat for each colour channel.

enter image description here

To make it more user friendly you can also setup a panel to display these properties at the side of the 3dview.

Here is an example file setup.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.