Nodes/WtlNodes/Camera Depth of Field
ComfyUI Node

Camera Depth of Field

Lens-accurate depth of field, not a blur-in-a-circle approximation

By Scorpiosis0·Created 10 months ago·Updated 2 months ago· 3
Camera Depth of Field
  • image
  • depth_map
  • image
  • blur_mask
  • in_focus_mask
  • out_of_focus_mask
  • border_mask
focal_point0.50
blur_strength10
focal_plane0.00
focus_falloff0.25
in_focus_mask_fix0
bokeh_shapecircle
highlight_factor0.00
highlight_threshold_low0.00
highlight_threshold_high1.00
preview_modeblur_mask
apply_type

Most "depth of field" filters in the wild are a gaussian blur with extra steps. Camera Depth of Field from WtlNodes is a real attempt at the thing itself: take an image and a depth map, pick where the lens is focused, and blur the rest as if a camera did it - with depth-graduated blur strength, physically-shaped bokeh kernels, and highlight bloom on the bright spots.

It's the pack's most ambitious image node, and it's squarely aimed at the "my render looks synthetic" problem. AI images are in focus edge to edge, and nothing screams "render" louder than that. Give this node a MiDaS-style depth map and a focal point, and the background dissolves into real-looking out-of-focus territory instead of a uniform smudge.

How it works

The depth map is used to decide how much blur each pixel gets, based on its distance from the focal plane. Crucially, the blur is applied in eight depth-graduated levels rather than one big filter, so near-focus pixels get a gentle blur and far pixels get heavy blur, with a smooth ramp between - which is how real optics behave. The bokeh shape is baked into the kernel: bokeh_shape of circle, hexagon, or octagon controls the look of out-of-focus highlights (hexagons read like classic 6-blade lens bokeh; octagons like 8-blade). And highlight_factor with the two threshold sliders lifts bright spots above a brightness band into bloom, mimicking how highlights flare when out of focus.

The inputs that matter

  • image and depth_map - the photo and its depth. Any depth map works; MiDaS output is the usual source. Feeding a good depth map is 80% of the result.
  • focal_point - 0 to 1: the fraction of depth where focus sits. 0.5 focuses mid-scene.
  • focal_plane - 0 to 0.5: how wide the in-focus band is. Small = shallow depth of field.
  • focus_falloff - 0 to 1: how abruptly blur ramps in beyond the focal plane. Lower = a bigger soft focus look.
  • blur_strength - 0 to 100: overall blur amount.
  • in_focus_mask_fix - an integer dilation (0–10) that expands the in-focus mask by pixels to clean up halos on edges. If you see a bright outline around in-focus subjects, bump this.
  • highlight_factor / highlight_threshold_low / highlight_threshold_high - the bloom: which brightness band gets the glow and how strong.
  • preview_mode - switches the preview between the blur_mask, the in_focus_mask, and the final image. This is the killer feature for tuning: see exactly what's blurred and why before committing.

The outputs

image plus four masks: blur_mask, in_focus_mask, out_of_focus_mask, and border_mask. The masks are genuinely useful downstream - for example, masking an inpaint region to just the out-of-focus area, or keying a sharp subject for compositing.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/Scorpiosis0/ComfyUI-WtlNodes.git

Restart ComfyUI, or install via ComfyUI Manager (search "WtlNodes"). No model downloads for the node itself - though you'll want a depth-estimation node (MiDaS etc.) to feed it.

Gotchas

  • Bad depth map = bad DOF. A depth map with holes or reversed values produces blur in the wrong places. The preview_mode masks will show you immediately whether the map is trustworthy.
  • It's slow-ish. Eight graduated blur levels plus optional bloom is real compute, not a cheap pass. Fine for a final image; annoying in a live workflow.
  • Highlight bloom needs a real brightness band. If highlight_threshold_low and high bracket nothing (e.g. 0 to 1 with highlight_factor at 0), you get no bloom - set the low threshold to catch the brights you want to glow.
CategoryWtlNodes/image

Inputs (13)

NameTypeDefaultDescription
imageIMAGE
depth_mapIMAGE
focal_pointFLOAT0.500–1
blur_strengthFLOAT100–100
focal_planeFLOAT0.000–0.5
focus_falloffFLOAT0.250–1
in_focus_mask_fixINT00–10
bokeh_shapeCOMBOcircle3 options: circle, hexagon, octagon
highlight_factorFLOAT0.000–1
highlight_threshold_lowFLOAT0.000–1
highlight_threshold_highFLOAT1.000–1
preview_modeCOMBOblur_mask3 options: blur_mask, in_focus_mask, image
apply_typeCOMBO3 options: none, auto_apply, apply_all

Outputs (5)

NameTypeDescription
imageIMAGE
blur_maskMASK
in_focus_maskMASK
out_of_focus_maskMASK
border_maskMASK