Nodes/MKRShift_Nodes/Lens Distort
ComfyUI Node

Lens Distort

Barrel, pincushion, and chromatic fringe in one pass

By criskb·Created 7 months ago·Updated 5 months ago· 0
Lens Distort
  • image
  • mask
  • image
  • mask
  • lens_distort_info
settings_json{"distortion":0.12,"chroma_aberration":0.05,"edge_vignette":0.22,"zoom_compensation":true,"mask_feather":12.0,"invert_mask":false}

No lens is perfectly flat. Real glass bends straight lines, darkens corners, and splits color along edges - and AI images have none of those flaws, which is exactly why they can look too clean to be real. Lens Distort is the MKRShift node that adds the whole optical-flaw bundle in one pass: barrel or pincushion distortion, chromatic aberration, and edge vignette. It's the "put this frame on an actual lens" node.

It's in MKRShift Nodes/VFX/Optics, the pack's lens-flaw lane. If you've ever shot through a wide-angle, you know barrel distortion - straight lines bow outward toward the edges. This node does that to a generated frame, plus the fringe and darkening that come with it. For the "de-AI" crowd this is a genuinely useful tool: the KB's photorealism doc keeps pointing at the same stack - grain, aberration, vignetting - and this node is two of those three in one click.

How it works

The node applies a radial distortion: distortion (default 0.12) is the strength, with sign deciding the direction. Positive gives you barrel (edges bow outward, the classic wide-angle look); negative flips to pincushion (edges pinch inward). zoom_compensation (on by default) rescales so the distorted frame doesn't leave gaps at the edges - keep it on unless you're deliberately going for a holey, anamorphic-gate look.

chroma_aberration (0.05) then shifts the red and blue channels by slightly different amounts as you move from center, producing that colored fringe along high-contrast edges - the thing phone cameras are always apologizing for. Small values read as "real lens"; big values read as "psychedelic," so start tiny.

edge_vignette (0.22) darkens toward the frame corners. It's the oldest photographic trick in the book: a slight corner falloff focuses the eye on the subject and makes literally any image feel more "shot."

Using it

Everything lives in one settings_json string, and the defaults are already a believable photographic starting point. Outputs: the distorted image, a mask, and a lens_distort_info string. The optional mask input scopes the effect, and mix fades the whole thing if you want to build it up gradually.

Practical chain: run it before your grain/finish pass, not after - real lens distortion happens in the glass, and the grain should sit on top of it. For a video sequence, distortion at 0.08–0.15 and chroma_aberration around 0.03–0.06 is the "shot on a decent zoom" band; anything more and it reads as an Instagram filter.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/criskb/MKRShift_Nodes

then restart, or search MKRShift_Nodes in ComfyUI Manager. No pip requirements, no model downloads - pure numpy resampling.

The trap is stacking too many lens flaws at once. Distortion plus aberration plus vignette each at "noticeable" levels adds up to an image that looks processed, which is the opposite of what you want. Pick one to feature - usually the vignette, it's the most forgiving - and keep the other two below the threshold where you'd notice them if you weren't looking.

CategoryMKRShift Nodes/VFX/Optics

Inputs (3)

NameTypeDefaultDescription
imageIMAGE
settings_jsonSTRING{"distortion":0.12,"chroma_aberration":0.05,"edge_vignette":0.22,"zoom_compensation":true,"mask_feather":12.0,"invert_mask":false}
maskoptMASK

Outputs (3)

NameTypeDescription
imageIMAGE
maskMASK
lens_distort_infoSTRING