1 The idea
Real lenses bend straight lines. Wide lenses usually bow outwards (barrel, negative k1 in this model); some long lenses bow inwards (pincushion, positive k1). CG always renders perfectly straight, so without distortion it slides near the frame edges.
The right way: undistort the plate only for tracking, then redistort just the CG so it bends like the lens. Never touch the hero plate.
x_d = x · (1 + k1·r² + k2·r⁴)2 Hands-on
Adjust k1 until the CG grid (cyan) sits on the plate’s lines (orange)
3 Deep dive
Why the edges get hit hardest
x_d = x(1 + k1 r² + k2 r⁴), where r is the distance from the lens centre (corner = 1). At the centre r ≈ 0 and nothing moves; towards the edges r² grows fast. In our model, with k1 = −0.05 a corner point moves 5% of its radius inwards, while a point halfway out moves only 1.25%.
The real lens centre is usually a little off the image centre, and each program uses its own model and normalisation, so a k1 from one program (even its sign) can’t be typed straight into another.
Getting the lens data
On set: shoot a lens grid (checkerboard) for every lens, and for a zoom at every focal length used. Fill the frame, keep the grid flat, square to the camera and sharp. Distortion can change with focus too, so shoot near the working focus distance if you can.
No grid: use lines in the plate that should be straight, like the poles or a building edge, and let the software straighten them. Less accurate than a grid, but far better than guessing.
- 1Lens grid on set
- 2Detect + Solve
- 3Master LD node
- 4Undistort / Redistort
The right order
Undistort a copy of the plate for tracking → solve → render CG in undistorted space → redistort only the CG → Merge over the untouched original plate. Every distortion resamples and softens, so the hero plate should never make the round trip.
Render the CG with overscan: a barrel redistort pulls pixels from outside the frame into the corners. Without it you get black slivers at the edges. A Crop added to trim the bbox must not cut that overscan away.
| Image | What it gets |
|---|---|
| Hero plate | Untouched |
| Plate copy for tracking | Undistort |
| CG / element | Redistort (with overscan) |
STMap: render once, share with everyone
An STMap is an image whose pixels store UV coordinates saying where to fetch colour from. Render undistort and redistort STMaps once and everyone on the team gets the same result, without needing the original lens node.
Quick check: a pole that is straight in the world must be straight in the undistorted plate.
4 In real work
In Nuke
- LensDistortion (may need NukeX, depending on your licence): Analysis → Detect on the lens grid, fix bad points, then Solve
- Keep a master LensDistortion in a backdrop and copy it, so a stray edit can’t spread
- Plate copy → LensDistortion (undistort) → CameraTracker
- ScanlineRender with overscan → LensDistortion (redistort) → Merge over the original plate
- LensDistortion can write the distortion as an STMap; apply it with the STMap node
- Use a sharper filter (e.g. Lanczos) for undistort, render and redistort
Common mistakes → the fix
- ✗ Undistorting the whole plate, comping, then redistorting everything back✓ Redistort only the CG and put it over the original plate
- ✗ Rendering CG exactly to frame✓ Render with overscan to avoid black corner slivers
- ✗ Copying k1 from one program into another✓ Hand it over as an STMap or use a node with the same model
- ✗ Blaming the track when CG slides only at the edges✓ Check distortion first
- ✗ Shooting a grid at only one focal length of a zoom✓ Shoot every focal length used
Before you send the shot
- A lens grid exists, or a solve from straight lines in the plate
- The hero plate never goes through undistort/redistort
- CG has overscan and no Crop cuts it off
- CG grid lines sit on the plate’s lines in the corners
- No black slivers at the edges after redistort
5 Check yourself
CG slides only near the frame edges while the centre holds. Likely cause?
🔒 Answer the question above and this card opens
1. Our model, k1 = −0.08. A point halfway from centre to corner (r = 0.5) moves by how much?
2. Why render the CG with overscan?
Where the numbers come from: Lens maths is the standard thin-lens model (FOV, CoC, hyperfocal), using CoC = sensor diagonal ÷ 1500, a common convention rather than a fixed rule. Distortion uses the Brown–Conrady model (k1, k2). The real DOF images are Blender Cycles renders.