A friend of mine was asking about easier ways to control depth of field in After Effects.
Although it isn’t complicated, AE cameras measure depth of field with a single number, measured in pixels. So, it isn’t very easy to visualize and estimate when and where
objects are in focus, aside from scrubbing the “Focus Distance” control and trying to put objects in focus by trial and error.
But, expressions come to the rescue. If we want focus distance to be equal to the distance between the camera and and exact, controllable point, we can do this. If we create a Null and use this as the point that we want in focus, we can add an expression to the Focus Distance to be equal to the length in pixels between the camera and the Null. Fortunately, there’s an expression term, “length” that retrieves the absolute distance between the anchor points of any two objects, regardless of position, rotation, scale, etc.
In the example here, the Focus Distance expression is:
length(thisComp.layer(”focusControl”).position, position)
So, it is the length between two numbers, think here in terms of length(a,b). The first number, via pickwhip, is the position of a Null called “focusControl”. The second number is shown as ‘position’. Being that this expression is on the camera’s Focus Distance, “position” in this case refers to the position of the camera. And that’s it!!! The expression will dynamically update the focus distance to be the exact distance between the Null and the camera. Just put the Null where you want something to be in Focus.
You could also just use the camera’s Point of Interest, with the expression like this:
length(pointOfInterest, position)
But, I like the Null, myself. As I often turn off the Point of Interest on my AE cameras.
Download the Focus Control project here