driver for scale and material color - cycles

I have a bad English, but now I try to explain

after seeing this https://plus.google.com/u/0/+MikhailRachinskiybyDesign/posts/fWZU3E58694 I wanted to try myself to change the material color and to simplify the preparation of objects and driver.
this is a test:

so I followed these steps:

  • added a cube and an empty
  • added a material
  • added the drivers for the scale x,y and z (right click in “scale” fields and “add drivers”)
    • scripted expression: “1-dist/sx”
    • variable “dist”: Distance; ob1:Empty, ob2:Cube
    • variable “sx”: single property; prop: Empty, path:“scale.x”
    • Channel - extrapolation mode: constant
    • copy driver for the y and z (change sx with sy, sz…)

We have a cube scaled/driven to the position and scale of Empty.

Now change the material.
You can not link/drive a node of the material to the distance from the empty, because the distance is from/to the single object and must have a different material for each object.
A solution is using the “object index” and add a driver in this field, in the “Object” tab:
- add driver
- scripted expression: “distInd”
- variable “distInd”: Distance, ob1: Empty, ob2: Cube
- Channel - extrapolation mode: constant
in this way the “object index” changes with the position/scale of the empty, and the “object index”, in the node “object info”, is used to take the color from a “color ramp”.

Ok, now is possible duplicate the cube:

  • added a array modifiers to the cube: 15 duplicates for the x
  • copy the array for y
  • copy the array for z
  • apply all arrays (without “merge” checked!)
  • [select the cube] enter in edit mode, select all, <P> (separate), choose “by loose parts”
  • exit edit mode (or enter object mode)
  • with all cubes selected: Shift-Ctrl-Alt-C (set origin) and choose “origin to center of mass”

We have 15x15x15 = 3375 cubes scaled/colored by the position and scale of Empty.

I tried to use the “custom properties” of the cube, to control the color, but I do not know how to access from within a cycles material :frowning:

here the blend of the video:https://drive.google.com/file/d/0B7o_GLlnugf9ZDlWVnhRUDJqM0k/view?usp=sharing

I hope it can help/inspire somebody…

Ciao!!

Fascinating! You’ve got a pretty cool effect going on there. :slight_smile:

Looks rather neat. Seems like it would make a good visual for music if controlled by baking sound to curves.