Matching Rack Focus In Nuke
A useful technique for matching the rack focus from the plate to your CG/elements…
A useful technique for matching the rack focus from the plate to your CG/elements…
If you're struggling to accurately match the rack focus in a plate, here's a technique that usually helps:
First, find the sharpest frame of the plate, and FrameHold it. By sharpest, I mean where the plate is in focus in the area (on the same focal plane) where you’ll be inserting your CG/element.
For example, if the rack focus goes from focusing on the foreground to focusing on the background, and you'll be placing an object in the foreground, the sharpest frame means where the plate is fully focused on the foreground.
Then, go to the most out-of-focus frame of the plate. Look for a bokeh or another feature that clearly displays the defocus in the area where you'll be inserting your object. This can for example be a light, a window, or some other distinct shape, which when defocused clearly blooms/smudges out to a different shape.
Next, either set up two Viewers or A/B wipe between the frameheld sharp frame and the defocused frame. View the same bokeh/feature that you picked earlier, in both Viewers.
Now, add your defocus node of choice to the frameheld sharp frame. Increase the defocus value until the feature that you picked matches between this frame and the defocused frame. (If you're trying to match a bokeh, you'll need a matching bokeh kernel input for your ZDefocus, this tutorial shows how to extract one).
Example of matching the bokeh size.
Next, at this most defocused frame, set a keyframe on the defocus value. Then, go to the sharpest frame and keyframe the defocus value to 0 (or the minimum value).
You can now detach your defocus node from the frameheld frame and attach it to your (sharp) CG render or element, and they should match up to the plate in terms of the rack focus.
Note that if you’re using a ZDefocus or similar defocus node with depth information, you’ll also/instead need to animate the focus plane value so that the focus (focal plane) will move correctly across your object. On the sharpest frame, sample your CG/element’s depth using the focal_point sampler in the Viewer, and set a keyframe on the focus plane value. Then, on the most out-of-focus frame, sample or input the new focus plane value, and set another keyframe. Animate the value as needed in between/outside of these two keyframes.
The great thing about using this technique is that you can often pretty easily get a perfect match. Because you are defocusing the same scene as the real lens did, and you already have a reference for what it should look like.
Focus Breathing
During a rack focus you may get (more or less subtle) focus breathing in the plate.
Focus breathing, also known as lens breathing, refers to a change in the apparent focal length when adjusting the focus, causing the image to appear slightly zoomed in or out.
If your CG/element looks like it's sliding slightly over the plate during the rack focus, you may need to counter-animate the movement with a Transform node for it to stay aligned.
You can achieve that by applying a Transform node to your CG/element, with the center point set to the centre of your image, and adjusting the scale value by a very small amount.
Using Real Life Metadata
A final tip:
If you have access to it, you can use the real life camera and shoot information to drive your rack focus.
By linking a ZDefocus node to real camera values and metadata from the shoot (distance from the camera to the object in focus), the focus will be calculated for you automatically.
Several tools have been built that can do this, such as PxF_ZDefocus, OpticalZDefocus or k_ZDefocus.
I hope you found this tutorial useful. For more Nuke tips & tricks, see Nuke.