Nodes/ComfyUI-NKD-VFX-Tools/😺NKD Lens Blur
ComfyUI Node

😺NKD Lens Blur

Depth of Field You Can Click, Not Beg For

By Nekodificador·Created 6 months ago·Updated a day ago· 155
😺NKD Lens Blur
  • rgb
  • depth
  • blurred_image
â—„blur_config{}â–º

A prompt can't reliably hand you "background soft, subject tack sharp." A focus plane and a fall-off are lens language, not sentence language - you can describe them, but the model will compromise on where they land. NKD Lens Blur is the deterministic version: a depth-of-field pass driven by a depth map, where you click where the focus should land and the blur falls off in front of and behind that plane. Preview updates live on the node, no queueing.

How it works

The math is a banded blur. Your depth map is turned into a scalar, and a focal band is centered on the focal depth - by default, the depth sampled at the point you click, plus whatever focalOffset you dial. Pixels inside the band get zero blur; pixels outside get blur that grows with distance from the band edge, shaped by a smoothstep so the ramp doesn't slam. The blur-amount map itself is spatially smoothed so you don't get hard rings at the focal-band edges, and the actual blur is applied from a bank of Gaussian kernels at increasing sigma. Alpha is never blurred, which matters if you're blurring something with a transparency channel.

The inputs that matter

  • rgb and depth - that's the whole cable side. depth needs to be a proper depth map; whichever Depth Anything or Marigold node you already have will do (this pack ships no models).
  • blur_config - a JSON string carrying the actual controls: blurStrength (your aperture), fieldOfDepth (how deep the in-focus band is), and focusX/focusY/focalOffset (where focus lands). You won't hand-edit this - the node's viewport is where you click focus and set the aperture, and the config widget just stores the state.

The single output is blurred_image, ready for the rest of your graph.

Where it fits

Two uses, both good. As a finishing pass on a generated frame, it's how you add a photographic focus fall-off the model didn't commit to. Or run it on the plate before the sampler - a soft background stays soft in the generation, which is a lot more reliable than asking the model to invent blur it was never conditioned on.

Install and gotchas

The whole pack installs in one move: ComfyUI Manager, search "NKD VFX Tools", restart. Nothing to download, numpy is the only hard dependency - torch comes with ComfyUI itself. If the blur lands on the wrong thing, check your depth map's convention first: if near is white it's a normal disparity map, and if your source flips that (far as white) you'll see the focus plane behave backwards - invert upstream, not here. This is a small, quiet node that does one job cleanly; it's the kind of thing you install for and forget it's there.

Category😺NKD Nodes/Utils

Inputs (3)

NameTypeDefaultDescription
rgbIMAGE—
depthIMAGE—
blur_configoptSTRING{}—

Outputs (1)

NameTypeDescription
blurred_imageIMAGE—