3 Replies Latest reply on May 8, 2015 10:26 PM by Rick Gerard

# Connecting an attribute value to Z-space

So it's a bit hard to explain but here is what I am trying to do.

Let's say I have a layer with Hue and Saturation effect. I am using an animated 3D sequence (rendered out of a 3D software) where the camera is moving through the space pointing at a 3d cube.

I would like to change the saturation of this sequence based on how far or close the cube is from the camera.

Is there anything out there that is possible?

• ###### 1. Re: Connecting an attribute value to Z-space

I actually managed to start something. If only I can link the saturation intensity to how black/white a reference layer is. Scripting maybe.

• ###### 2. Re: Connecting an attribute value to Z-space

Saturation is a single value and not an array so you should be able to take the distance between the camera and the cube or a null positioned at the center of the cube and tie that to the saturation control using a linear expression. All of the language is available from the pop up expression language menu in the timeline. I'm replying with my phone  so I am not going to attempt to write an expression at this time.

• ###### 3. Re: Connecting an attribute value to Z-space

Ok, Saturation is a single value in the Color Balance HLS effect so you would apply that effect and then add this expression

point1 = thisComp.layer("Camera 1").position;

point2 = transform.position;

t = length(point1, point2);

s = linear(t, 1000, 2000, 0, -100);

Here's how it works. Under Vector math you find length(point1, point2) so to measure the distance, no matter what the angle between the camera and the current layer's position you define point1 and the camera's position and point2 as the layer's position. If you were using a null placed at the center of a cube then you would apply the Color Balance HLS effect to the layers you want to change saturation and define point2 as thisComp.layer("Null 1").position. Then from the interpolation menu you'll find the linear methods as linear(t, tMin, tMax, value1, value2). The length between the camera and the layer is t and so when the distance between the camera and the layer changes from 1000 pixels to 2000 pixels the saturation would go from zero or no change to -100, the maximum value to desaturate. You just have to know how far the camera is moving to achieve your desired effect.

Does that make sense???