Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Need help building an expression to drive Out of Focus plugin

  • Need help building an expression to drive Out of Focus plugin

    Posted by Colin Day on August 16, 2006 at 10:34 pm

    I despise the way the AE camera depth of field looks, so I prefer using something like Frischluft Lenscare Out of Focus for depth of field effects. I’m looking for a way to use an expression to automatically drive the blur amount for the Out of Focus plugin based on an object’s distance from the camera.

    I can figure out how to generate the distance from the camera, but the tricky part is giving the focus a sweet spot so that objects that are, say, 250 pixels away from the camera are in focus, but any further away or any closer to the camera, they start to get more and more out of focus.

    Has anyone on the board done this before? If not, how could I drive the out of focus blur amount based on the object’s distance from the camera?

    Scott G replied 19 years, 7 months ago 2 Members · 1 Reply
  • 1 Reply
  • Scott G

    September 29, 2006 at 7:24 am

    i’m working on this at the moment, here’s where i am so far – blur works on z distance. it’s easy enough to change this for camera position, just subtractt the position of the layer from the position of the layer, and multiply by -1 if it’s a negative value.

    you need a null object with a slider effect on it. name the slider “Divider”

    positionz = position[2];
    divider = thisComp.layer(“Slider”).effect(“Divider”)(“Slider”);
    multiplier = -1;
    blur = positionz/divider;
    if (blur < 0) { blur = blur*multiplier } else { blur } blur; the problem i'm having at the moment is figuring out what to do if the camera rotates. i need to calculate distance from the front of the camera, is the direction that the camera is facing, rather than simply relying on z-space calculations. z is fine if all you're doing is flying in and out, but what if you turn 90 degrees? nothing will look right. never was perfect at maths, and not sure how the rotation (or orientation) of the camera factors in?

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy