Working with Lens Distortion

Lens distortion can make compositing work more difficult because the characteristics of the lens can cause areas of the footage to warp, making correct placement of assets problematic. One way around this problem is to undistort your plate before starting work on a comp and then redistort and merge only the VFX work to produce the final comp.

The original plate

The undistorted plate and comp

The comp after redistortion

It's a good idea to shoot grids with the same lenses you use to create your footage as this makes estimating distortion easier. If you have the lens properties, such as Focal Length and Sensor Size, and a grid shot with the same lens you'll find this process much less painful.

Nuke's LensDistortion node allows you to undistort or distort an image according to several radial distortion models that ship with Nuke or a custom model you define yourself. You can calculate the warp for use on the input image or output the warp to an STMap for use elsewhere in the script.

Quick Start

Here's a quick overview of the workflow:

1.   Read in an input sequence, connect it to a LensDistortion node (Transform > LensDistortion), and connect the output to a Viewer.
2.   If you have a grid shot using the same lens as your sequence, use Grid Detection to calculate the distortion, and then apply the warp to your sequence. See Estimating Lens Distortion Using a Grid and Removing Lens Distortion from an Image for more information.
3.   If you do not have a grid, or Grid Detection did not work, draw features and lines manually to estimate distortion and undistort the sequence. See Estimating and Removing Lens Distortion Using Lines for more information.

Note:  If you want, you can calculate the lens distortion on one image and apply that distortion to another image with the help of an STMap node. For more information, see Working with STMaps.

4.   Add your VFX work to the undistorted sequence.
5.   Redistort the VFX work and merge it over the original plate. See Applying Lens Distortion to an Image for more information.