I have a field of ellipsoids with various rotations. I'd like to colour them by their rotation. Is it possible to get an object's rotation in a cycles material node?

  • $\begingroup$ AFAIK, For controlling via location, you can use Object Info node. But via rotation... It would be a nice feature too. A new vector type for object Info node. :) I bet currently you have to script for batch control. $\endgroup$ Commented May 25, 2014 at 8:31
  • $\begingroup$ I wonder if adding it would be trivial.. I might have to see if I can get myself on the development team :) $\endgroup$
    – ajwood
    Commented May 26, 2014 at 13:18

2 Answers 2


Sort of..

You can insert a "Value" node (under Input) into your Cycles shader, then add a driver to it (right-click the parameter and select Add Driver); get the driver to copy the rotation axis of whatever object you want to use:

  1. With the Value node selected, go to the Graph Editor.
  2. Switch mode from F-Curves to Drivers.
  3. On the left hand side of the editor, find the "Value" inside Material > Shader Nodetree and click on it.

At this point you might need to reveal the panel at the right hand side of the editor - hit N if you can't see it.

  1. In the "Drivers" panel, change "Type" to "Averaged value".
  2. In the variable panel, make sure "Transform channel" is selected, then specify your Object from the input by name, change Type to "X Rotation" (or Y rotation, etc) and you should see its current value appear.

You can then attach the output of your Value node in Cycles to a Hue/Saturation node, or to the Fac of a Mix node to alter the colour. If you want each rotation axis to be available in the material, add a separate value for each rotation axis.

If you want to do something like map each axis directly to a part of the colour - e.g. X becomes R, Y becomes G, Z becomes B - add an RGB input node instead, right click the colour and add a driver to that. You can then find it under "Drivers" the way you might have found the value, and you can drive the four different components of the colour (R G B and A) individually.

Worth noting: the rotation value will hit the driver as radians, not degrees. It's also possible that the driver will get an input which is less than zero - you can get around this to an extent by setting the Type to Scripted Expression and using an expression like "abs(var) % pi" to keep the colour away from black.

There's an annoying drawback to this method though: as far as I know, you'll need to set the driver and material up separately for each object - so you'll end up having as many copies of the material as you have colour-changing ellipses. If your Cycles node setup is particularly complicated and you still want to be able to tweak it, you might try Grouping all the nodes in your material except for the Value, but use the Value as an input to your group. If the Object Node had X/Y/Z Location/Rotation/Scale, this wouldn't be necessary.

  • $\begingroup$ I can't get this to work. I've tried using rotations between -1000 to several thousand degrees to see if range was a problem and there is no difference in the output. Oddly enough, if I change the slider for the Value node, the rendered output changes even though I get a message saying "Cannot edit a driven value, see graph editor for the driver setup." $\endgroup$ Commented May 24, 2014 at 9:00
  • 1
    $\begingroup$ Well it works.. the annoying drawback to pointed out is going to make this impossible though (I'm applying the material to a couple hundred or so objects), so I'll have to script it. $\endgroup$
    – ajwood
    Commented May 24, 2014 at 14:57

Thank you to quollism who mentioned drivers can do this, i've attached some visuals to help guide the process.

To get data into a node that isn't normally supported by existing "Input" nodes,

we can use Blender Drivers

I find it useful to having a animation playing working with drivers. animation playback is recommended

  1. Rotation in blender is often represented as an XYZ Euler, first x, then y, then z, so we need to copy three values to copy a rotation
  2. I recommended adding one "combine XYZ" converter, since this will directly operate as a vector in nodes, but three individual "input values" works too
  3. select the rotation source, I believe this value, when sampled by the driver will be "fully updated", including all parent transforms in its transform. Copy this, Object -> Rotation, X right click "Copy as New Driver"
  4. select the rotation destination (our Combine XYZ's X input), right click "Paste Driver"

repeat for all X Y Z components,

this works in compositing and geometry nodes too I believe.

Source X Copy as New Driver Dest X Paste Driver
enter image description here enter image description here enter image description here enter image description here

(repeat 3x)

Shown below is a visual of the process, (its too big to be a gif so it won't embed directly)



You must log in to answer this question.

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