Nodes/Radiance/Defocus
ComfyUI Node

Defocus

Cinematic defocus from a depth map, bokeh shape and all

By FXTD-Studios·Created 9 months ago·Updated 3 days ago· 249
Defocus
  • image
  • depth_map
  • image
◄blur_amount5.0►
◄focus_distance0.50►
◄focus_range0.10►
◄bokeh_shapeCircle►
◄highlight_boost1.0►
◄foreground_blurtrue►
◄use_gputrue►

Depth of field is one of the strongest "this was shot on a real camera" signals an image can have, and it's one of the hardest things to fake well in post. Radiance Depth of Field is the node that does it: it blurs your image based on a depth map, so the background falls out of focus while the subject stays sharp, instead of the flat "blur everything" you get from a plain Gaussian.

The mechanism is the standard trick from the depth-estimation world: a depth map (bright = near, dark = far, or the opposite if you invert it) tells the blur how strong to be at every pixel. Areas far from the focus plane get blurred hard; areas on it don't. Feed it the output of Radiance's own Depth Map Generator - the two are designed to pair - and you get a one-stop defocus pass. Feed it no depth map at all and it degrades to a flat blur, which is only worth doing for a stylized look.

The inputs that matter

  • image - the frame to blur.
  • depth_map - optional, but this is the node's whole reason to exist. Without it you get uniform blur; with it, defocus.
  • blur_amount - 0 to 50, default 5. How strong the maximum blur gets.
  • focus_distance - 0 to 1, default 0.5. Which depth value is in focus. Tune this to move the sharp band through the scene.
  • focus_range - how deep the in-focus band is. Small = razor-thin, large = deep focus. This is your f-stop in disguise.
  • bokeh_shape - Circle, Hexagon, Octagon, or Anamorphic Oval. Approximates the aperture's physical shape in the out-of-focus blur. The anamorphic oval is the one that sells the cinema look - oval highlights and horizontal streaks read as "anamorphic lens" instantly. Note the caveat: it's approximate. For real anamorphic character you'd still add streaking in a compositor.
  • highlight_boost - 1 to 3. Makes bright out-of-focus highlights bloom into bokeh discs instead of dull smears. This is what separates a convincing fake DoF from a blur filter.
  • foreground_blur - on by default. Real lenses blur foreground elements too; turn it off if you want only the background to fall off.

Output is a single IMAGE at the same size you fed in.

Where it fits

This is the payoff node for the depth map: ControlNet uses depth for generation, but DoF is the post side, and it's the move that makes a flat render read as a camera shot. Pair it with Radiance Film Grain and a grade and you've got most of the "shot on film" checklist without re-rolling the generation. One honest note: the pack's marketing overstates the 32-bit pipeline in places (the launch thread caught nodes dropping to 8-bit), and this node is a blur - it won't recover detail that was already lost, and it's only as good as the depth map you feed it. A noisy or mispolarized depth map makes halos, so use the Depth Map Generator's blur_edges to smooth it first.

Install

In the fxtdstudios/radiance pack - Manager search "Radiance", or:

cd ComfyUI/custom_nodes
git clone https://github.com/fxtdstudios/radiance.git
cd radiance
pip install -r requirements_linux.txt   # or windows/mac_silicon

Restart after; Linux needs libopenexr-dev before pip. Heavy dependency set (OpenEXR, OpenColorIO, colour-science, transformers) means a slow first boot, and if Manager's security level blocks the install, the README's manual clone is the workaround.

CategoryFXTD STUDIOS/Radiance/VFX

Inputs (9)

NameTypeDefaultDescription
imageIMAGEImage or frame batch to defocus. Works on linear or display-encoded values; super-whites are kept.
blur_amountFLOAT5.00–50Maximum defocus in pixels: Gaussian sigma for Circle (kernel capped at 31 px), kernel radius for the other shapes. Below 0.1 the image is returned unchanged.
depth_mapoptIMAGEDepth in 0-1 from the first channel, 0 = near, 1 = far; resized to the image. Without it, a radial map is used (sharp centre, blurred corners).
focus_distanceoptFLOAT0.500–1Depth value that is in focus, on the depth_map scale (0 = near, 1 = far). With no depth map, 0 is the frame centre.
focus_rangeoptFLOAT0.100.01–0.5Depth distance either side of focus_distance that stays sharp; blur then ramps up to full over the rest of the depth range.
bokeh_shapeoptCOMBOCircleAperture shape. Non-circular shapes use a convolution kernel for physically accurate bokeh.
highlight_boostoptFLOAT1.01–3Brightens defocused highlights (luma above 0.8) by up to this factor, scaled by the amount of blur. 1.0 = off.
foreground_bluroptBOOLEANtrueBlur areas nearer than focus_distance (depth below it). Off keeps the foreground sharp and blurs only the background.
use_gpuoptBOOLEANtrueRun the effect on GPU via CUDA/MPS. Falls back to CPU if unavailable.

Outputs (1)

NameTypeDescription
imageIMAGE—