How to Match Depth-Pass Fog to Camera Depth of Field in Blender’s Compositor
To match compositor fog to camera depth of field, first decide where the blur happens. For a Cycles render with camera DOF already applied, use the Mist pass as your starting fog mask. For a workflow controlled entirely in the Compositor, mix fog into a sharp render before applying Defocus, using the original Z pass to drive focus.
This tutorial focuses on Blender 4.5 LTS and an opaque Cycles scene. The task is to make distance fog follow the scene’s visible focus transitions without leaving crisp silhouettes around blurred objects. Both methods are approximations; the checks below help you choose which one suits your image.
Why does depth-pass fog look sharper than the rendered scene?
Blender’s Z pass records distance to the nearest visible surface. It is not anti-aliased, and Blender explicitly notes that it can produce noisy results when the render uses depth of field or motion blur. The manual recommends Mist for a cleaner image in those circumstances. Blender Manual: Passes
Consider an illustrative scene containing a nearby blue cylinder, a focused ceramic cube, and a distant orange sphere. Camera DOF makes the cylinder’s outline soft. If a fog mask still describes a crisp cylinder silhouette, the fog blend can reveal that hard boundary inside the soft image. Increasing fog strength makes the mismatch more obvious.
The important distinction is between fog amount and blur amount. Distance fog can increase continuously toward the background. Depth-of-field blur instead has a minimum around the focus distance and increases away from it. Blender’s camera documentation describes objects in front of and behind the focused distance becoming blurred. A white-is-distant fog mask therefore cannot serve unchanged as a camera-matched blur-radius mask. Blender Manual: Cameras
Which workflow should you choose?
Choose according to the image you already have and the kind of adjustment you need.
| Starting point | Recommended approach | Main limitation |
|---|---|---|
| Cycles image already rendered with camera DOF | Blend fog using the rendered Mist pass | Cleaner coverage does not guarantee an exact fog-and-DOF reconstruction |
| Sharp render with editable compositor DOF | Mix fog first, then apply Defocus | Single-image Defocus has limitations around overlapping objects |
| EEVEE render with camera DOF | Test a fog-before-Defocus workflow from a sharp render | EEVEE does not render DOF into passes other than Combined |
| Strong foreground blur with important background detail | Consider separate depth layers or rendered volume fog | Requires more scene and render preparation |
The engine distinction matters: Blender 4.5 documents EEVEE’s depth of field as available in Combined rather than the other passes. Do not assume a Mist-based fix will behave identically across render engines. Blender Manual: Passes — EEVEE Limitations
The following node arrangements are practical recommendations derived from the documented pass and node behavior. They should be judged against your shot rather than treated as a numerical guarantee of matching rendered lens blur.
How do you use Mist when camera DOF is already rendered?
In Cycles, start by keeping your existing camera DOF and replacing the raw Z-based fog mask with Mist. Blender maps Mist into a 0–1 range, with controls for its starting distance, transition depth, and falloff. Enable the pass in View Layer Properties before looking for its settings in World Properties. Blender Manual: World Settings — Mist Pass
- In
View Layer Properties → Passes → Data, enableMist. - In
World Properties → Mist Pass, chooseLinearfalloff for an easily interpreted initial test. - Set
Startto the distance where fog should begin andDepthto the distance over which it should reach full strength. - Render again so the enabled pass is available.
- In the Compositor, connect Render Layers
Imageto inputAof a Mix Color node set toMix. - Set input
Bto a pale fog color and connect Render LayersMisttoFactor. - Send the mixed result to Viewer and Composite.
With this arrangement, black mask areas retain the image, white areas become the fog color, and intermediate values blend the two. That follows the Mix node’s factor-controlled interpolation between its A and B inputs. Use ordinary Mix for this test so fog strength has a clear interpretation. Blender Manual: Mix Color Node
For the fictional object scene, try Start = 4 and Depth = 8, with the focused cube approximately six scene units from the camera. The transition ends at twelve units because Mist Depth is measured from Start, rather than being an absolute end distance. These are illustrative values; choose distances appropriate to your scene. Blender Manual: World Settings — Mist Pass
Inspect Mist directly before reshaping it. A steep Color Ramp can turn a smooth transition into an abrupt edge. If the original Mist pass looks suitable but the processed version looks cut out, reduce the remapping before adding another blur node.
How do you make fog and DOF share one compositor operation?
When you can start from a sharp render, mix the fog into that image and then defocus the complete result. This gives the fogged color and object color the same downstream blur operation, avoiding a sharp fog blend added after the scene has already been blurred.
First, save a camera-DOF reference render. Record the camera’s focus target or focal distance and aperture settings. Then disable rendered camera DOF for the compositor version while retaining the intended focus settings. Render again with Z and Mist enabled. Blender’s Defocus node uses scene camera data when supplied through Render Layers, while its own F-Stop controls the compositor blur. Blender Manual: Defocus Node
Build these connections:
- Render Layers
Image→ Mix ColorA. - Fog color → Mix Color
B. - Render Layers
Mist→ Mix ColorFactor. - Mix Color result → Defocus
Image. - Original Render Layers
Depth/Z output → DefocusZ. - Defocus result → Viewer and Composite.
In Defocus, select the relevant scene and keep No Z-buffer disabled when using the actual Z pass. Start with the reference camera’s f-stop, then compare the result visually. Match the available bokeh shape and rotation where relevant; identical f-stop values alone are not a promise of identical rendered and compositor DOF. Defocus is documented as a post-processing simulation. Blender Manual: Defocus Node
Do not apply this full-image Defocus step to the original already-blurred render when your goal is to reproduce its camera DOF. Use the newly rendered sharp image as the input, so there is one deliberate DOF operation.
How should you remap depth without losing focus information?
Keep two separate branches: a distance-data branch for Defocus and a remapped branch for fog. The original Z values belong at Defocus’s Z input. A fog factor belongs at the Mix node’s Factor input.
If you prefer Z-based fog for the sharp-render workflow, connect Z to a Map Range node. Set its source range to your chosen fog distances, its target range to 0–1, and enable Clamp. Blender documents these controls as remapping values between ranges and restricting the output to the target range. Blender Manual: Map Range Node
For example, use From Min = 4, From Max = 12, To Min = 0, and To Max = 1. The following values are a worked linear-remapping illustration for individual depth samples, not measurements from a render:
| Surface distance | Fog factor | Intended contribution |
|---|---|---|
| 2 units | 0 | Original surface color |
| 6 units | 0.25 | 25% fog-color blend |
| 8 units | 0.50 | Halfway blend |
| 12 units or farther | 1 | Fog color |
Send that remapped result only to the fog blend. Feeding it into Defocus as though it were raw depth changes the distance information. Conversely, enabling No Z-buffer makes the input control blur radius directly; that mode requires a deliberately designed blur mask rather than an unchanged distance-fog gradient. Blender Manual: Defocus Node
How can you check whether the fog actually matches?
Use the blue cylinder, ceramic cube, and orange sphere as a diagnostic arrangement. Give them contrasting matte colors and position them at clearly separated distances. Let the nearby cylinder overlap part of the distant sphere, because overlapping silhouettes expose problems that isolated objects can hide.
Compare three versions at the same output resolution and display settings: the image without fog, the fog mask alone, and the final composite. Inspect at 100% zoom before judging the whole composition.
- Check the focused cube. Its important edges should retain the intended focus. If the whole scene becomes soft, check focus settings and Defocus mode before changing fog strength.
- Check the nearby cylinder’s silhouette. Look for a narrow crisp line within its soft outline. Compare the unmodified mask against any ramped or remapped version.
- Check the distant sphere. Confirm that its increasing fog and increasing blur remain separately adjustable. Moving the fog start should change haze without moving the focus plane.
- Check the overlap. Look for pale fringes, dark outlines, or background color spreading across the foreground incorrectly.
- Check a second focus distance. Move focus from the cube toward the sphere and rerender. The sharpest region should move, while fog still follows distance.
This is a proposed visual test, not a reported render result. A useful match preserves the intended sharp region, avoids conspicuous fog boundaries, and remains coherent when focus changes. Matching only the average softness of the background is insufficient.
What if halos or mismatched edges remain?
First isolate the cause. Bypass Defocus to inspect the fog blend, then bypass fog to inspect DOF. If each looks acceptable alone but their combination fails, reconsider operation order or the separate handling of image and mask.
Even a cleaner Mist pass cannot guarantee exact reconstruction after camera DOF. As a mathematical inference, blending an already-averaged image with an already-averaged fog mask generally differs from averaging individually fogged samples: averaging a product is not generally the same as multiplying averages. This difference matters most where foreground and background contribute to the same blurred pixel.
Single-image Defocus also lacks the hidden background information needed for some strongly blurred foreground overlaps. Blender’s documentation identifies this limitation and suggests separating nearby and distant objects into different renders for demanding focus transitions. Blender Manual: Defocus Node — Hints
For such shots, consider separate foreground and background layers, or move the atmosphere into the scene using a volume workflow; Blender lists world volume shading as an alternative to Mist-based fading. That changes the rendering approach and needs its own test. Blender Manual: Passes
Keep the workflow that passes your silhouette and focus checks with the fewest corrective operations. Mist is the practical first test for existing Cycles camera blur; fog followed by Defocus gives clearer control when starting from a sharp render. Judge the match at the focused object and at overlapping soft edges, where the result is easiest to assess.