Nodes/Allor Plugin/ImageEffectsLensBokeh
ComfyUI Node

ImageEffectsLensBokeh

Real blade-shaped bokeh, not just a fat blur

By Nourepide·Created 3 years ago·Updated 2 years ago· 296
ImageEffectsLensBokeh
  • images
  • IMAGE
blades_shape5
blades_radius10
blades_rotation0.00
blur_size10
blur_type
method

A plain Gaussian blur smears highlights into soft discs, but real camera bokeh comes from the shape of the lens aperture - that's why out-of-focus lights in photos are pentagons or hexagons, not circles. ImageEffectsLensBokeh from the Allor plugin is the node that reproduces that: you pick the number of aperture blades and it shapes the blur kernel accordingly. If you're chasing photorealism on a background, this is the difference between "blurred" and "shot on a real lens."

How it works

The node builds a polygon kernel from your blades_shape (3 and up - 5 gives you the classic pentagon), blades_radius (how big the aperture polygon is), and blades_rotation (0–360, to orient it). That polygon is turned into a blur kernel, sharpened slightly with a laplacian-style edge boost, and applied with one of two methods:

  • dilate - uses OpenCV dilation with the shaped kernel. Fast, and it preserves the aperture shape strongly.
  • filter - a proper filter-2D convolution with the normalized polygon kernel. Softer, more authentic falloff, and it pre-dilates the image slightly to keep highlights round.

You can also run a pre-blur with blur_type (bilateral, stack, or none) at blur_size strength, which smears the detail first and then applies the shaped bokeh on top - that's the combination that reads as "long-lens background."

Inputs that matter

  • images - the IMAGE or batch to process.
  • blades_shape - number of aperture blades; 5–6 looks the most "real lens." Default 5.
  • blades_radius - aperture polygon size; bigger = chunkier bokeh discs.
  • blades_rotation - rotate the aperture so the shapes don't look perfectly axis-aligned.
  • blur_size and blur_type - the pre-blur. bilateral + stack are the realistic options; none leaves the hard edges in place.
  • method - dilate or filter; try filter first for smoothness.

Output is a single IMAGE, same size as the input.

Installing it

It's part of the Allor pack, one install for everything:

cd ComfyUI/custom_nodes
git clone https://github.com/Nourepide/ComfyUI-Allor

Restart ComfyUI (or use ComfyUI Manager → search Allor Plugin). First launch installs rembg and onnx from requirements.txt - slow once, then done. No models needed for this node.

Gotchas

  • This is CPU-bound OpenCV work, and filter mode with a big blades_radius can get slow on high-res images. Start at the defaults and raise blades_radius only if the bokeh reads too weak.
  • For a proper look, run the pre-blur first - bokeh applied to a sharp image just looks like a shapes filter. blur_type stack is a good default.
  • Same pack-wide warning as all Allor nodes: the repo history was rebased, so old clones can hit git pull failures. Re-clone if auto-update breaks.

If you want edge darkening to go with it, ImageEffectsLensVignette from the same pack is the natural companion.

Categoryimage/effects/lens

Inputs (7)

NameTypeDefaultDescription
imagesIMAGE
blades_shapeINT5
blades_radiusINT10
blades_rotationFLOAT0.000–360
blur_sizeINT10
blur_typeCOMBO3 options: bilateral, stack, none
methodCOMBO2 options: dilate, filter

Outputs (1)

NameTypeDescription
IMAGEIMAGE