Sampling a range of colors to apply to layers based on their position...

Sampling a range of colors to apply to layers based on their position...
by Chris Mellor on Apr 19, 2012 at 5:15:38 pm

Alright so I need some help with setting up expressions...

I have a cluster of layers (1000 of them) all randomly scattered (and moving) in 3D space. Basically like a school of fish. I want the closest objects to be white, while the farthest one is blue. And every one in between pulls from the color gradient of white>blue.

There are "falloff" presets available, like VideoCopilot for example, but these are all relative based on the camera's distance. I want to be able to move the camera, but have the color range stay in tact.

Now I am beginning with the method used in this Red Giant tutorial, where they use a color sampling expression to pull from set points on a gradient layer. I set up my gradient (white>blue) and set about 200 Point Controls to get vector data out of the colors. But how do I apply this color range to the position range of my objects?

Assuming my closest object has a max zPosition of -200 and the farthest object has a max zPosition of 200 (ranges I have set with expressions already), how do I say, for each layer, "Where is your position in the range of -200 to 200? Now change your color according to the color gradient specified"