Fading out object relative to object position (Object Info tips?)

In Cycles I have a cube with a red diffuse material on it, parented inside a larger Empty (type ‘cube’). The Empty can be re-positioned anywhere, moving the cube with it as you’d expect.

I want to animate the red cube – JUST the red cube, not the Empty – to 0,0,-2 BU in the Empty’s local space. As the cube moves, the red cube should fade to invisibility.

The key point is: I need to make cube fade out due to the cube’s movement from the Empty, not a deliberate keyframe animation in the node editor or compositor. The cube’s material transparency value is calculated from the local space distance from the Empty.

I’m guessing the node to use is Object Info in materials, and somehow configure it so that -2 BU in the Z-axis means the red diffuse shader transitions to a transparent fader via Fac input. But I don’t know how to manipulate Object Info’s output. Any help?

I would use a driver which calculates both object’s z location in world space

, subtracts them and divides by 2. This drives the mix factor with transparency.

zdriver on dropbox

Attachments