Camera Depth of Field
Lens-accurate depth of field, not a blur-in-a-circle approximation
- image
- depth_map
- image
- blur_mask
- in_focus_mask
- out_of_focus_mask
- border_mask
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
imageanddepth_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 theblur_mask, thein_focus_mask, and the finalimage. 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_modemasks 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_lowandhighbracket nothing (e.g. 0 to 1 withhighlight_factorat 0), you get no bloom - set the low threshold to catch the brights you want to glow.
Inputs (13)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| depth_map | IMAGE | — | |
| focal_point | FLOAT | 0.500–1 | — |
| blur_strength | FLOAT | 100–100 | — |
| focal_plane | FLOAT | 0.000–0.5 | — |
| focus_falloff | FLOAT | 0.250–1 | — |
| in_focus_mask_fix | INT | 00–10 | — |
| bokeh_shape | COMBO | circle | 3 options: circle, hexagon, octagon |
| highlight_factor | FLOAT | 0.000–1 | — |
| highlight_threshold_low | FLOAT | 0.000–1 | — |
| highlight_threshold_high | FLOAT | 1.000–1 | — |
| preview_mode | COMBO | blur_mask | 3 options: blur_mask, in_focus_mask, image |
| apply_type | COMBO | 3 options: none, auto_apply, apply_all |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| blur_mask | MASK | — |
| in_focus_mask | MASK | — |
| out_of_focus_mask | MASK | — |
| border_mask | MASK | — |