ComfyUI Node

Depth FX

Fake depth of field and atmospheric haze, no depth model required

By criskb·Created 7 months ago·Updated 5 months ago· 0
Depth FX
  • image
  • depth_map
  • mask
  • image
  • depth_mask
  • depth_info
settings_json{"depth_mode":"luma","focal_depth":0.5,"depth_range":0.25,"near_blur":10.0,"far_blur":18.0,"depth_contrast":1.0,"haze_strength":0.15,"haze_r":0.74,"haze_g":0.82,"haze_b":0.92,"mask_feather":12.0,"invert_mask":false}

Want your generated image to look like it was shot on a real lens with a real plane of focus? x1Depth ("Depth FX") does the classic photographic trick of faking depth of field and distance haze on a flat image - and unlike a lot of "depth" nodes in the ecosystem, it doesn't need a depth model at all. It will happily work from luminance alone.

It's part of MKRShift Nodes, the single-pack finishing suite by Cris K B, sitting under MKRShift Nodes/VFX/Concept.

How it works

The node builds a depth falloff from one of four depth_mode sources: luma (bright = near), inverted_luma, radial (a circle out from center - great for that fake tilt-shift vignette), or custom_map. With a focal_depth value (0–1) and a depth_range you pick where the sharp band sits and how deep it is. Then it applies two separate Gaussian blurs: near_blur for the pixels closer than focus and far_blur for everything behind it, so you can have a softer background than foreground, just like a real lens.

The second trick is haze_strength with haze_r/g/b tint - as things get farther from the focal plane, the node mixes them toward a haze color (default a pale blue-grey). That's atmospheric perspective, the cheap way to sell depth in landscapes and city shots where defocus alone reads as "washed out" rather than "distant."

The honest caveat: luma-based depth is a hack. Bright sky is "near," dark shadow is "far," which is why the node also takes an optional depth_map MASK input. If you feed it a real depth map from MiDaS, Depth Anything, or MoGe (the depth-estimation world the KB covers), custom_map mode turns this from a parlor trick into an actual cinematographer's tool - blurred background that follows real geometry instead of brightness. If you have a depth map already, wire it in; if not, luma with a tight depth_range is a surprisingly convincing one-node DoF.

The inputs that matter

All in the settings_json blob:

  • depth_mode - luma (default), inverted_luma, radial, or custom_map.
  • focal_depth and depth_range - where the focus band sits and how wide it is.
  • near_blur / far_blur - blur strength in pixels for each side of focus.
  • haze_strength + haze_r/g/b - distance haze amount and color.

Optional inputs: depth_map (a MASK) and a regular mask for localizing the whole effect. Outputs are image, depth_mask (the computed depth falloff - handy if you want to reuse it elsewhere), and a depth_info string.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/criskb/MKRShift_Nodes

Restart, or use ComfyUI Manager and search MKRShift_Nodes. Zero pip dependencies, no models to download for the luma/radial modes. (If you're feeding a real depth map, that comes from wherever you already load depth maps - the node doesn't generate one for you.)

Gotchas

Don't crank far_blur past 20-ish on a 1024px image and expect anything but mush - blur radius is in pixels and it's a plain Gaussian, so huge radii just homogenize. Start with near_blur around 8–10 and far_blur 14–18, then widen. And remember the mask_feather / invert_mask JSON keys work like every other node in this pack: malformed JSON silently resets to defaults, so edit the default string in place rather than typing fresh.

CategoryMKRShift Nodes/VFX/Concept

Inputs (4)

NameTypeDefaultDescription
imageIMAGE
settings_jsonSTRING{"depth_mode":"luma","focal_depth":0.5,"depth_range":0.25,"near_blur":10.0,"far_blur":18.0,"depth_contrast":1.0,"haze_strength":0.15,"haze_r":0.74,"haze_g":0.82,"haze_b":0.92,"mask_feather":12.0,"invert_mask":false}
depth_mapoptMASK
maskoptMASK

Outputs (3)

NameTypeDescription
imageIMAGE
depth_maskMASK
depth_infoSTRING