Nodes/Post Processing PRO/Lens Distortion PRO
ComfyUI Node

Lens Distortion PRO

Barrel and pincushion distortion, done with actual lens math

By Guillaume-127·Created 5 months ago·Updated 5 months ago· 2
Lens Distortion PRO
  • image
  • IMAGE
distort0.010
zoom1.05

AI images are too geometrically perfect. Real photos taken on real lenses have barrel distortion (edges bulge outward, classic on wide angles and phone cameras) or pincushion distortion (edges pull inward, common on telephotos). It's one of the things that separates "rendered" from "captured" - and it's also a genuinely practical tool: if you're compositing AI generations over real footage, your render needs to inherit the footage's lens warp or it will never sit convincingly. Lens Distortion PRO exists for exactly that.

This is the pack's optics workhorse. Where Veiling Glare PRO fakes light and Lateral Chromatic Aberration PRO fakes color fringe, this one actually solves the real optical equation - the Brown-Conrady radial distortion model used in camera calibration software everywhere.

How it works

The node builds a distortion map using the Brown-Conrady radial model: for each pixel, it computes the squared distance from the frame center, normalizes it, and applies a distortion factor of 1 + distort × r². Positive distort pushes source pixels outward - barrel expansion - and negative pulls them inward - pincushion. A zoom factor then compensates for the image shrinkage that barrel distortion causes, which is the crucial practical detail: distort without zoom leaves black, un-filled corners, because the image physically warps away from the frame edges.

It's implemented with cv2.remap using Lanczos interpolation and reflect-edge border padding, so the warp stays smooth and nothing hard-cuts at the boundaries. If you've ever used a lens-correction slider in Lightroom, this is the same math running backwards.

The inputs that matter

  • image - the IMAGE to warp.
  • distort (default 0.01, range ±0.2) - the radial distortion strength. Positive = barrel (bulging), negative = pincushion. The default is a whisper; realistic lens profiles usually live around ±0.02–0.05.
  • zoom (default 1.05, 1.0–1.5) - how much to zoom in to cover the warp. Leave it at the default and you won't see black corners on mild distortion; if you push distort hard, you may need more zoom.

Output is an IMAGE of the same resolution.

Installing it

One of 14 nodes in the Post Processing PRO pack. ComfyUI Manager → search "Post Processing PRO", or:

cd ComfyUI/custom_nodes
git clone https://github.com/Guillaume-127/ConfyUI_Post_Processing_PRO

Restart. No requirements file, no model downloads - OpenCV remap on a precomputed grid, fast enough for CPU.

Where people get tripped up

Three things. First, the corner problem: with distort above ~0.05, the zoom at 1.05 may not be enough and you'll see the reflect-padded edges creeping in. Crank zoom, or keep distortion modest - this is a subtlety tool, not a fisheye. Second, direction: a positive value bulging outward is easy to confuse with pincushion when you're eyeballing a preview; test on a grid or a straight line (a door frame works) to confirm you've got the curve you wanted. Third, it pairs with the pack's other optics for a full "shot on glass" stack - distortion for geometry, Lateral Chromatic Aberration PRO for edge fringing, Veiling Glare PRO for the hazy light. On their own each is subtle; stacked, a render stops looking like a render.

CategoryPost_Processing_PRO/Optics

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
distortFLOAT0.010-0.2–0.2
zoomFLOAT1.051–1.5

Outputs (1)

NameTypeDescription
IMAGEIMAGE