ComfyUI Node

MX_LensOpticAxis

Fake lens distortion with a bonus mask output

By Intersection98·Created 2 years ago·Updated 2 years ago· 13
MX_LensOpticAxis
  • images
  • IMAGE
  • MASK
lens_shape
lens_edge
lens_curvy4.0
lens_zoom2.0
lens_aperture0.5
blur_intensity30

LensOpticAxis is the pack's simulated lens-distortion node. It bends and blurs your image as if it were seen through an optical element - a pinhole-ish center that stays sharp while the edges smear outward - and, unusually, it hands you the mask it used as a second output. That second output is the sleeper feature: you get a shape/feather mask for free, ready to drive compositing or a vignette.

It's part of Intersection98/ComfyUI-MX-post-processing-nodes. It's one of the three "lens" nodes in the pack, alongside MX_LensBokeh and MX_LensZoomBurst, and it's the most parametric of the three - the one with the most knobs to learn.

How it works

The node builds a radial mask (lens_shape defines its geometry - circle, square, rectangle, or corners), then uses it to decide how much each pixel gets pulled toward the frame's center by a distance-based remap. The lens_aperture value scales that pull, so the mask doesn't just select - it distorts. The masked region then gets a stack blur (blur_intensity), and the final image is the sharp center blended against the blurred, shifted edges through the mask. Two implementation details are worth knowing: the internal lens_zoom gets +1 added before use, and blur_intensity gets -1 - the source nudges the numbers so your inputs behave intuitively, but it means tiny values aren't quite what they look like. The mask output is the same radial mask, remapped to match, so it aligns exactly with where the effect was applied.

The inputs that matter

  • images - your IMAGE tensor.
  • lens_shape - circle, square, rectangle, corners. The geometry of the "lens" region.
  • lens_edge - around (mask from center out to edges) or symmetric (centered, cropped to your aspect ratio).
  • lens_curvy - how rounded/squared the falloff is. Higher = harder-edged.
  • lens_zoom - how much the masked region magnifies.
  • lens_aperture - the distortion strength. This is the dial that actually makes the image bend.
  • blur_intensity - the blur applied to the shifted edge region.

The node returns two outputs: IMAGE (the distorted result) and MASK (the aligned shape/feather mask). Wire the IMAGE to a save node and the MASK into any compositing step - that free mask is genuinely useful for vignette-style effects.

Install

Standard MX pack install. ComfyUI Manager (search MX or ComfyUI-MX-post-processing-nodes), or:

cd ComfyUI/custom_nodes
git clone https://github.com/Intersection98/ComfyUI_MX_post_processing-nodes
cd ComfyUI_MX_post_processing-nodes
pip install -r requirements.txt

Restart ComfyUI; it's under postprocessing/lens. No model downloads - this node leans on OpenCV's remap and stackBlur, so the pack's opencv-python dependency is doing real work here.

Where people get burned

This is the fiddliest node in the pack, and the honest advice is to budget some dial-twiddling time. The defaults are deliberately mild, so a first run can look like almost nothing happened - push lens_aperture up before you judge it. The non-square symmetric mode is the one real edge case: on a portrait image it pads to a square, computes, then crops back - fine in principle, but worth knowing if your output looks slightly differently framed. And because the distortion pulls pixels toward center, the frame edges can end up slightly soft or slightly shifted - that's the lens simulation doing its thing, not an error. If you only want the mask and not the distortion (a clean radial gradient for a vignette), set lens_aperture low and grab the MASK output - it's a perfectly good radial gradient generator hiding inside a lens node.

Categorypostprocessing/lens

Inputs (7)

NameTypeDefaultDescription
imagesIMAGE
lens_shapeCOMBO4 options: circle, square, rectangle, corners
lens_edgeCOMBO2 options: around, symmetric
lens_curvyFLOAT4.0
lens_zoomFLOAT2.0
lens_apertureFLOAT0.5
blur_intensityINT30

Outputs (2)

NameTypeDescription
IMAGEIMAGE
MASKMASK