FL Depth Blur
Real depth-of-field from a depth map, not just a mask
- image
- depth_map
- protect_mask
- image
- blur_amount_viz
- in_focus_mask
Most "blur the background" nodes in ComfyUI just gaussian-blur based on a flat mask - one focal plane, one blur amount, done. FL Depth Blur is the version that actually reads distance: hand it your image plus a depth map from any depth estimator upstream in your graph, and it produces a proper lens-like falloff - sharp at your chosen focal depth, progressively blurrier the further a pixel sits from it in either direction.
The mechanism
It precomputes a set of blur kernels (gaussian, box, or disc - disc is the one that gives you that hexagonal bokeh-shaped out-of-focus look real lenses produce), builds a per-pixel "how blurry should this be" map from your focal depth and a falloff curve, then lerps between the sharp and blurred layers using that map. It's the same conceptual approach a compositor uses for defocus, just running on a diffusion-pipeline depth map instead of a 3D renderer's Z-buffer.
Inputs and outputs that matter
image and depth_map are both required IMAGE inputs - the depth map is doing the actual work, so a bad depth map means a bad blur no matter what else you tune. focal_depth (0-1, default 0.5) sets where in the depth range stays sharp; focal_range (0-1, default 0.1) is how wide that sharp zone is before falloff kicks in; max_blur (0-64, default 12) caps how blurry the farthest pixels get. falloff_curve (linear / quadratic / smooth / exponential) shapes how aggressively blur ramps with distance - quadratic, the default, reads more natural than linear. blur_mode picks gaussian/box/disc as above.
near_blur_strength and far_blur_strength (both 0-1) blur the foreground and background independently - useful for a sharp subject with a soft background where you don't want stuff drifting toward the lens to blur symmetrically. depth_invert flips which end of the map counts as "close," which matters because different depth estimators disagree on convention. depth_remap_low/depth_remap_high rescale the usable depth range if your map is compressed into a narrow band. bokeh_brightness_boost (1-4) punches up bright spots in the blur to fake blown-out lens highlights. mask_feather softens the edge of the optional protect_mask input if you want to hard-protect a region - a face, say - from blurring regardless of its depth value.
Outputs: image (the result), blur_amount_viz (an IMAGE visualizing the blur-strength map - genuinely useful for debugging a region that isn't blurring the way you expect), and in_focus_mask (MASK, marking what landed in the sharp zone).
Installing it
ComfyUI Manager: search Fill-Nodes, install, restart. Manually: cd ComfyUI/custom_nodes && git clone https://github.com/filliptm/ComfyUI_Fill-Nodes, then restart. No model download needed - it's pure image processing on whatever depth map you feed it.
Where people get burned
Depth map quality is the whole game. A noisy or low-contrast depth map produces blotchy, inconsistent blur that no amount of falloff-curve tweaking fixes - check blur_amount_viz before touching any other slider if a result looks wrong. And watch depth_invert early: if cranking focal_depth toward 1.0 blurs your foreground instead of your background, your depth map's convention is flipped relative to what this node expects, and no other slider will fix that either.
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| depth_map | IMAGE | — | |
| focal_depth | FLOAT | 0.500–1 | — |
| focal_range | FLOAT | 0.100–1 | — |
| max_blur | FLOAT | 12.00–64 | — |
| depth_invert | BOOLEAN | false | — |
| falloff_curve | COMBO | quadratic | 4 options: linear, quadratic, smooth, exponential |
| near_blur_strength | FLOAT | 1.000–1 | — |
| far_blur_strength | FLOAT | 1.000–1 | — |
| blur_mode | COMBO | gaussian | 3 options: gaussian, box, disc |
| quality_steps | INT | 84–24 | — |
| depth_smoothing | FLOAT | 1.00–10 | — |
| depth_remap_low | FLOAT | 0.000–1 | — |
| depth_remap_high | FLOAT | 1.000–1 | — |
| bokeh_brightness_boost | FLOAT | 1.001–4 | — |
| mask_feather | FLOAT | 2.00–32 | — |
| show_preview | BOOLEAN | false | — |
| protect_maskopt | MASK | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| blur_amount_viz | IMAGE | — |
| in_focus_mask | MASK | — |