ComfyUI Node

Optical Compensation

Fake a lens without buying one

By lazniak·Created 2 years ago·Updated 11 months ago· 7
Optical Compensation
  • image
  • IMAGE
field_of_view90.0
convergence-45.0
chromatic_aberration-20.0
blend_modescreen
edge_blur0.00
edge_roundness0.50
feather_width0.30
interpolationbicubic
buy_me_a_coffeefalse
usage_counterUsage count: 0

Optical Compensation is a lens-simulation node: it takes an image (or a batch of frames) and applies field-of-view, barrel/pincushion distortion, chromatic aberration, and an edge-falloff treatment, returning a transformed IMAGE. If you've ever wanted your generated footage to look like it came off a GoPro, a fisheye, or a slightly imperfect vintage lens, this is the cheap way to do it - no lens, just a remap.

The core control is convergence, and it's the one you'll touch most. Negative values bow the image outward (barrel distortion, the fisheye look - the default is -45), positive values pinch it inward (pincushion, which is also how you correct barrel distortion from a real wide lens). field_of_view (default 90°) stretches or compresses the perspective around that. chromatic_aberration (default -20) splits the RGB channels so you get the color fringing that cheap or wide lenses produce - crank it for a visible glitchy fringe, keep it small for a subtle realism bump. The remaining trio - edge_blur, edge_roundness, feather_width - build a vignette-style edge treatment with a feathered gradient, useful for that "shot on a real lens with falloff" finish. blend_mode (screen or additive) and interpolation (bicubic/bilinear/nearest) round out the list.

How it works

Per frame, it remaps pixels based on your settings - the distortion is a geometric remap, the aberration is a per-channel displacement, and the edge treatment is a radial blur with a configurable falloff. It processes your whole batch, which is the point for video work: apply the same lens character to every frame of a clip and the shot looks coherently "filmed." It's CPU-friendly per-frame work; long clips take a while but nothing is held in VRAM permanently.

One expectation-setting note, because the README for this pack is aggressively enthusiastic: it claims GPU shaders, ray tracing, aspheric element simulation, and a shader pipeline. The actual code is torch/PIL per-frame math. It still does what it says on the tin - the distortion and aberration effects are real and decent - but it's a simple image transform, not an optical simulator. Adjust expectations, enjoy the results.

Install & troubleshooting

Same pack install: Manager search "videoclipgenerator", or git clone https://github.com/lazniak/videoclipgenerator into custom_nodes + pip install -r requirements.txt, restart. It lives under "image/transform".

Troubleshooting: push convergence or field_of_view to extremes and pixels get shoved off-frame, leaving transparent or smeared edges - keep magnitudes in the tens, not hundreds. Heavy aberration at big values can also show up as ugly fringing on fine detail, which is the point if you want it and an artifact if you don't. And yes, this node has the pack's buy_me_a_coffee checkbox that opens a browser tab when ticked - leave it false.

Categoryimage/transform

Inputs (11)

NameTypeDefaultDescription
imageIMAGE
field_of_viewFLOAT90.01–360Field of view angle in degrees
convergenceFLOAT-45.0-200–200Controls the strength and direction of the compensation effect (+: concave, -: convex)
chromatic_aberrationFLOAT-20.0-200–200Adds RGB channel separation
blend_modeCOMBOscreen2 options: screen, additive
edge_blurFLOAT0.000–1Amount of blur at the edges (0-1)
edge_roundnessFLOAT0.500–1Controls the roundness of edge blur gradient (0-1)
feather_widthFLOAT0.300–1Width of the feathered edge gradient (0-1)
interpolationCOMBObicubicInterpolation Method
buy_me_a_coffeeBOOLEANfalseSupport development with a coffee! ☕
usage_counterSTRINGUsage count: 0Tracks how many times this node has been used across all your projects

Outputs (1)

NameTypeDescription
IMAGEIMAGE