Groups > Multimedia > Adobe After Effects expressions > Re: Modifying the opacity/distance to camera chesnut...




Modifying the opacity/distance to camera chesnut...

Modifying the opacity/distance to camera chesnut...
Fri, 18 Apr 2008 16:30:04 -070
I'm using this old standby to make distant layers fade in as they get closer to
the camera:

startFade = 500; // Start fade 500 pixels from camera.
  endFade = 1500; // End fade 1500 pixels from camera.
  try{ // Check whether there's a camera.
      C = thisComp.activeCamera.toWorld([0,0,0]);
  }catch(err){ // No camera, so assume 50mm.
      w = thisComp.width * thisComp.pixelAspect;
      z = (w/2)/Math.tan(degreesToRadians(19.799));
      C = [0,0,-z];
  }
  P = toWorld(anchorPoint);
  d = length(C,P);
  linear(d,startFade,endFade,100,0)

Post Reply
Re: Modifying the opacity/distance to camera chesnut...
Fri, 18 Apr 2008 22:24:35 -070
Try changing the last line to this:

Math.min(linear(d,0,startFade,0,100),linear(d,startFade,endFade,100,0))

Post Reply
Re: Modifying the opacity/distance to camera chesnut...
Mon, 21 Apr 2008 11:49:51 -070
Hey Dan! That works great. I have both startFade and endFade connected to
Expression Sliders.

With your new line, how do I control how close the layer is to the camera before
it starts to fade? (Right now, it's fading out a little late and the image is
becoming too pixellated)

Post Reply
Re: Modifying the opacity/distance to camera chesnut...
Thu, 24 Apr 2008 06:09:14 -070
That should work. Then just change the last line to this:

Math.min(linear(d,nearFade,startFade,0,100),linear(d,startFade,endFade,100,0))

Post Reply
Re: Modifying the opacity/distance to camera chesnut...
Thu, 24 Apr 2008 07:38:54 -070
Post Reply
about | contact