# Depth maps, defocus and depth atmosphere

> Create depth maps and normals in Nodespell, then refocus with Defocus and ZDefocus, shape bokeh, and add haze and fog with Depth Atmosphere.

Source: https://docs.nodespell.com/edit/depth-and-defocus/ · Last updated: 2026-11-10

Depth effects in Nodespell turn a depth map, a grayscale image where brightness means distance, into lens blur and atmosphere. You create the depth map with a depth model node, then use **ZDefocus** to refocus the shot, **Defocus** for uniform lens blur, and **Depth Atmosphere** for haze, fog and diffusion that grow with distance.

## Create depth maps and normals

Depth and normal model nodes run as tasks on Nodespell and return images you can feed into effects.

| Node                        | Input | Outputs                                                        | Notes                                                                                                                                                        |
| --------------------------- | ----- | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Depth Anything V3 Image** | Image | **Result**                                                     | Grayscale depth: near is white, far is black. **Output format** PNG (default), JPEG or WebP; use PNG to avoid compression                                    |
| **Depth Anything V3 Video** | Video | **Result**                                                     | Temporally consistent depth video at the source resolution, keeping the audio, up to 30 fps; clips up to 10 minutes                                          |
| **Facet Depth V1**          | Image | **Depth map (PNG)**, **Depth (EXR)**, **Raw depth (NPY)**      | EXR and NPY keep floating-point depth. **Scale** (0.2–2) resizes the input, up to 12 megapixels. **Ignore transparent objects** estimates depth behind glass |
| **Facet Normals V1**        | Image | **Normal map (PNG)**, **Normals (EXR)**, **Raw normals (NPY)** | Camera-space normals, not tangent-space texture maps                                                                                                         |

All of these give relative depth, not distance in metres. When you bring depth or normals into a colour-managed compositor, assign them **Raw / data** in its Inputs so no colour transform changes the values. See [Color management](https://docs.nodespell.com/edit/color-management/).

## Defocus or ZDefocus?

|             | **Defocus**                                     | **ZDefocus**                                  |
| ----------- | ----------------------------------------------- | --------------------------------------------- |
| Blur amount | The same everywhere (**Radius**, default 16 px) | Varies with depth from the **Depth** input    |
| Use for     | Out-of-focus elements, backgrounds, bokeh looks | Refocusing a shot, rack-focus, depth of field |
| Extra input | **Kernel** (custom aperture)                    | **Depth** and **Kernel**                      |

Both share the same apertures, quality setting and highlight controls, and both work in the Graph and in compositors.

## Refocus a shot with ZDefocus

1. Connect the image to **ZDefocus** and the depth map to its **Depth** input.
2. In the **Depth** tab, set **Depth Channel** (default **Luminance**) and **Depth Encoding**: **White Near** (default, as Depth Anything and Facet output) or **Black Near**. Use **Depth Min** and **Depth Max** to map your values to the 0–1 range.
3. Set **Output** to **Depth View** to check the normalised depth, then **False Colour Focus** to see what is in focus.
4. Set **Focus Depth** (0–1, default 0.5) to the depth that should stay sharp, and **Focus Range** (default 0.04) for how much depth around it stays sharp.
5. In the **Defocus** tab, set **Max Radius** (default 24 px) and the **Near Blur** and **Far Blur** strengths (default 1).
6. Set **Output** back to **Result**.

| **Output**             | Shows                                         |
| ---------------------- | --------------------------------------------- |
| **Result**             | The refocused image                           |
| **Depth View**         | Normalised depth                              |
| **Blur View**          | Blur amount per pixel                         |
| **False Colour Focus** | Near, focused and far areas in colour         |
| **Kernel**             | The aperture shape at its size on the picture |
| **Layer Setup**        | How depth is split into blur layers           |

ZDefocus renders depth in layers. **Automatic Layers** (on) chooses spacing from the radius and quality; turn it off to set **Layers Per Side** (default 20) and **Layer Curve** (0 is even; positive packs layers near focus). Foreground blur spreads beyond object edges. **Edge Anti-aliasing** smooths the silhouettes of focused objects against the depth map, with **Strength**.

## Choose a bokeh shape

**Aperture** sets the lens shape for both nodes. New nodes use **Disc**; nodes saved earlier keep their blade aperture.

| **Aperture** | Extra controls                                                                                                                                                            |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Disc**     | **Edge softness**, **Rim strength**, **Rim width**                                                                                                                        |
| **Blades**   | **Bokeh Sides** (3–16, default 7), plus the Disc controls                                                                                                                 |
| **Star**     | **Bokeh Sides**                                                                                                                                                           |
| **Heart**    | None                                                                                                                                                                      |
| **Ring**     | **Hole size** (default 0.5)                                                                                                                                               |
| **Image**    | Uses the picture on the **Kernel** input: **Kernel from** (**Auto**, **Brightness**, **Alpha**), **Kernel centre** (**Shape bounds** or **Image frame**), **Noise floor** |

**Aspect** stretches the aperture, for an anamorphic look, and **Rotation** turns it. For an image kernel, connect a white shape on black, or a shape cut out of transparency; raise **Noise floor** to clean a photographed kernel. Set **Output** to **Kernel** to see the shape the blur uses.

**Highlight Threshold** and **Highlight Gain** (default 0, off) boost bright areas before blurring so bokeh balls bloom. This is a creative adjustment for SDR footage; HDR values above 1 already produce bright bokeh. **Quality** is **Fast** (default, smaller working resolution) or **High quality**; preview and export use the same setting. During playback in a compositor, heavy defocus may show a half-resolution preview that is replaced by full quality when you pause.

## Add haze and fog with Depth Atmosphere

**Depth Atmosphere** builds haze, dense fog and diffusion from a depth map. Connect **Image** and an aligned **Depth**; **Mask** is optional. It is a screen-space approximation: it cannot see hidden geometry, cast volumetric shadows or handle several depth layers per pixel.

| Tab            | Controls                                                                                                                                                                                                                            |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Atmosphere** | **Start** (0.05) and **End** (1) distances, **Air Density** (0.35, up to 20), **Maximum Opacity** (0.9), **Air Colour**, **Falloff**, **Falloff Power** and **Falloff Curve**                                                       |
| **Grade**      | **Exposure** (stops), **Contrast** and **Saturation**, applied more with distance                                                                                                                                                   |
| **Diffusion**  | **Image Diffusion** softens all distant detail; **Highlight Bloom** (0.35) spreads light from bright areas, with **Highlight Threshold**, **Soft Knee**, **Radius** (80 px), **Blur Layers**, **Layer Growth** and **Tail Falloff** |
| **Depth**      | **Depth Channel**, **Depth Encoding** (**White Near** default), **Decode sRGB Depth**, **Depth Min**, **Depth Max**, **Mask Softness** (1 px) and **Edge Anti-aliasing** (1)                                                        |

**Falloff** is **Exponential** (default), **Linear** or **Custom**. With **Custom**, draw the distance ramp as a curve: its endpoints are fixed, points can be smooth or linear, and you can open a larger editor. **Falloff Power** shapes the ramp before the falloff is applied. Turn on **Decode sRGB Depth** only for a depth map stored as an sRGB image; leave it off for numeric depth.

Set **Output** to inspect parts of the effect: **Result**, **Atmosphere Only**, **Distance Influence**, **Transmission**, **Highlight Bloom**, **Diffused Image**, **Fog Mask** or **Diffusion Mask**.

## Frequently asked questions

### Which depth model should I use?

Use Depth Anything V3 Image for a quick grayscale map and the Video node for moving shots. Use Facet Depth V1 when you need floating-point depth in EXR or NPY.

### Why is my focus inverted?

Your depth map may use black for near. Set **Depth Encoding** to **Black Near**.

### Are depth values in real-world units?

No. These models produce relative depth. Use **Focus Depth**, **Depth Min** and **Depth Max** to work in the normalised 0–1 range.

### Can I animate the focus?

Yes, inside a video Compositor. Key **Focus Depth** for a rack focus; see [Keyframes](https://docs.nodespell.com/edit/keyframes/).

### Do Defocus and Depth Atmosphere use credits?

They run on your GPU in the browser. The depth and normal model nodes run as tasks on Nodespell.

## Related

- [Recipe: depth refocus and atmosphere](https://docs.nodespell.com/recipes/depth-refocus-and-atmosphere/): a worked example.
- [Filters and effects](https://docs.nodespell.com/edit/filters-and-effects/): other blurs and filters.
- [Masks and keying](https://docs.nodespell.com/edit/masks-and-keying/): depth maps as mattes.
- [Color management](https://docs.nodespell.com/edit/color-management/): keep depth data raw.
- [Keyframes](https://docs.nodespell.com/edit/keyframes/): animate focus.
