-
opacity: distance from camera
Hey all.. first of all, I’m pretty new to expressions so please bare with me. I understand the concept and it’s alot like actionscripting in Flash, which i have a pretty good grasp on, but there are minor differences that I haven’t quie figured out yet. Anyway, on to the question…
I have a line of 3D pictures in a comp, z-space distributed evenly. This comp is nested into a “MASTER” comp. I would like the pictures to fade opacity as they get further away from the camera in the master comp. So when you first see the pictures, the closest one is opaque, and the furthest one is pretty much transparent. As the line of pictures moves towards the camera, I would like each picture to become more opaque as it gets closer to the camera.
I found this thread which deals with pretty much the same issue: https://forums.creativecow.net/thread/227/8737#8737
I applied this expression to each image’s opacity:
C = comp(“MASTER”).activeCamera;
startFade = thisComp.layer(“opacity controller”).effect(“start”)(“Slider”);
endFade = thisComp.layer(“opacity controller”).effect(“end”)(“Slider”);
d = length(toWorld(anchorPoint),C.toWorld([0,0,0]));
linear(d,startFade,endFade,100,0)The only thing I changed from the other thread was to link the startFade and endFade parameters to a slider, so i would only have to adjust that once.
Now, when I initially set this up, it seemed to work perfectly..

But as I scrub through the timeline, the opacity values don’t seem to update as the image positions change..

So where’s the catch? What am I missing to make this work right? I’m thinking it has something to do with nesting a 3d comp and trying to set the values based on the distance from the camera in the outer comp. I’m not real familiar with the whole “length” and “toWorld” stuff either, so maybe I need to tweak that too, not really sure..
Any ideas from the expression masters out there?