Brylka – TooDee – PanicPost

3D & Nuke

lens distortion workflow

Occasionally, but not often enough I need undistorted plates for tracking, 3D and compositing. Because of this
I noted down this little workflow to help out my memory when it was again too long ago…


Here is a 21mm Cooke S4 lens on a Arri Alexa filming on SxS cards in 1920×1080.

21mm_1280_UD


The undistorted grid. Using the ,LensDistortion‘ node in NukeX with Grid Analysis.
This undistorted sequence gets cropped, ignoring that some pixels are cut off at all edges. to 1920×1080 and
passed over to the 3D tracking software.

Blender_1280_demo_render


Now In the 3D Software you would normally render out the full 1920×1080 image.

Blender_1280_demo_distort


The problem is as soon as you apply the inverted lens distortion transformation in Nuke on that image the edges might
get stretched inwards thus creating artifacts on the edges of the frame.

One workaround is to adjust the horizontal and vertical aperture of the tracked camera and multipy it by a factor. For this
example I use the factor of 1.1. If your fov was 35mm, it now becomes 35/1.1=31.818181818mm.
Also increase the render size in the 3D application with the same factor. The new render size will be 2112×1188 pixels.

Blender_1408_demo_render


The darker grey area is the original 1920×1080 frame within the new 2112×1188 render size.

Blender_1408_demo_distort


Applying again the lens distortion in Nuke will stretch the edges of the frame, but not in the important 1920×1080 area.
Then use  a 2D transformation after the distortion to match the frame center of the 1920×1080 and the 2112×1188 rendering. The center of the HD frame is at 960×540. A transform of x= – 96 and y=- 54 pixels is needed when using a overscan factor of 10%.

Nuke_demo_script
The little Nuke script…
Blender_1408_demo_comp
and the result.