-
help with Dan’s “auto focus” expression… but more complicated
Hi Dan,
I’ve been playing with your auto focus expression as I wanted to add some depth of field to my invigorator objects.
the way you explained it was great and i had it working in no time.I’ve set it up slightly different to your original example. I have a null parented to my camera, and this null can slide back and forth along the z axis, and drives my focus distance, so i can pull focus midway through a shot. i imagine it like a trombone, with the camera as the mouthpiece and my focus null as the sliding hand-piece.
so what i’m doing is calculating the projected distance (if i’m using the correct terminology?) from my invigorator null, to this focal-depth null, to give me my blur amount. if they occupy the same plane, it’s in focus. if my object moves towards or away, it goes out of focus, or if i animate my focus null to pull focus from background to foreground, it works too. all is good.
problem: when i spin my invigorator null around so it tumbles through space, the z’s are not always pointing at each other, so i’m getting fluctuating distance.
i’m confusing myself trying to work out to which layer my expression should apply. i’ve got this expression on my tumbling invigorator null:
target = thisComp.layer(“CameraFocus(Z)”);
v1 = target.toWorld(target.anchorPoint) – toWorld([0,0,0]);
v2 = toWorldVec([0,0,1]);
dot(v1,v2)but i suspect needs to be the other way around, with the expression on my focus null, not my invigorator null. but since i have a lot of objects, it made sense to apply the distance expression to each object’s null, rather than trying to contain all the expressions on the focus null.
how would you go about setting something like this up?
is there a way to use the dot function to generate auto-focus when one of your layers in tumbling through space with animated x, y, AND Z rotations?thanks,
scott.