# After Effects Expressions

Currently Being Moderated

## Focus distance speed to brightness filter expression

### Jan 7, 2012 7:49 AM

Hi- I'd like to create an expression that links the speed at which a camera's focus distance changes to a brightness filter.

So, for example, if the focus distance changes abruptly and quickly, I want an image to suddenly get brighter proportionate to how fast the focus distance changed. Conversely, if the speed at which the focus distance changes is slow, then there should be very little change in the image's brightness.

Even better, if you could tell me how to make the brightness changes lag by about a half a second after the focus distance changes have occured, that would be great!

Thanks so much!

Replies
• Currently Being Moderated
Jan 7, 2012 9:36 AM   in reply to Under C

This will link the brightness to the focus distance rate of change with a delay:

atten = 20;

delay = .5;

thisComp.layer("Camera 1").cameraOption.focusDistance.speedAtTime(time-delay)/atten

Adjust the "atten" variable to tune the relationship between speed and brightness.

Dan

|
Mark as:
• Currently Being Moderated
Jan 7, 2012 7:57 PM   in reply to Under C

I forgot about negative speed. This should fix that problem:

atten = 20;

delay = .5;

C = thisComp.layer("Camera 1");

Math.abs(C.cameraOption.focusDistance.speedAtTime(time-delay))/atten

Your second question requires a much more complicated expression. The expression would have to loop back, frame-by-frame to figure out how long ago the most recent transition in the focal distance occured and use that time to drive some kind of decaying pulse for the brightness. It sounds like fun--I wish I had time to work it out for you.

Dan

|
Mark as:
Actions

#### More Like This

• Retrieving data ...

#### Answers + Points = Status

• 10 points awarded for Correct Answers