Nodes/Virtuoso Nodes for ComfyUI/Lens Blur with Depth Map
ComfyUI Node

Lens Blur with Depth Map

The closest thing in this pack to real depth-of-field

By chrisfreilich·Created 2 years ago·Updated about a year ago· 93
Lens Blur with Depth Map
  • image
  • depth_map
  • IMAGE
components4
exposure_gamma2.00
num_layers10
min_blur1
max_blur100

Combine the pack's two most photographic-looking ideas - a lens-simulated blur with actual bokeh shapes, and depth-map-driven selectivity - and this is the node you get. Where Gaussian Blur with Depth Map gives you a soft, generic depth-of-field, this one gives you the more photographic version with proper out-of-focus highlight shapes. If you're trying to make an AI render look like it came out of a camera with a fast lens, this is the node in the pack built for exactly that.

How it works

Same layered approach as the other depth-aware blur nodes: the depth map gets split into num_layers bands, and each band is blurred with the Lens Blur algorithm - a simulated aperture with components blades and exposure_gamma controlling how blown-out the resulting highlights look - at a strength interpolated between min_blur and max_blur based on how bright that band is. The bands then get recombined into a single output. Because it's running the full lens-simulation per depth layer rather than a simple average, this is one of the heavier nodes in the pack computationally - expect it to take noticeably longer than the Gaussian depth variant, especially with a high num_layers.

The inputs and outputs that matter

  • image - the picture to blur.
  • depth_map - a grayscale depth image from an upstream depth estimation node.
  • components (1–6, default 4) - virtual lens aperture blade count; lower gives sharper polygonal bokeh, higher trends rounder.
  • exposure_gamma (-100 to 100, default 2) - shapes how bright the blurred highlights look.
  • num_layers (1–100, default 10) - depth bands calculated; more is smoother but slower.
  • min_blur / max_blur (1–100, default 1 / 100) - blur strength at the darkest and lightest points of the depth map.

Output is a single IMAGE.

How to install it

ComfyUI Manager: search Virtuoso Nodes for ComfyUI, install, restart. By hand:

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

Restart. You'll need a depth map source feeding this node - a depth preprocessor pack like comfyui_controlnet_aux upstream in your graph, since this node consumes a depth map rather than producing one.

Common issues & troubleshooting

Blur is landing on the subject instead of the background. Check the polarity of your depth map before anything else. Per the README, lighter areas here get blurred more, and most standard depth preprocessors output white for close subjects. Unmodified, that means your foreground blurs and the background stays sharp - the reverse of typical portrait depth-of-field. Invert the depth map upstream if you want the classic look.

This is taking a long time to run. Between the lens simulation and the layered depth calculation, this is the most compute-heavy node in the blur family. Drop num_layers first (4–6 instead of the default 10), and if it's still too slow, prototype the composition with the plain Lens Blur node (no depth) before switching to the depth-aware version for a final pass.

Highlights look muddy instead of crisp bokeh discs. Try adjusting components - values around 4–6 tend to give the most visibly polygonal, photographic-looking highlights; very low values can look overly angular depending on the image.

CategoryVirtuoso/Blur

Inputs (7)

NameTypeDefaultDescription
imageIMAGE
depth_mapIMAGE
componentsINT41–6
exposure_gammaFLOAT2.00-100–100
num_layersINT101–100
min_blurINT11–100
max_blurINT1001–100

Outputs (1)

NameTypeDescription
IMAGEIMAGE