Metlivi Studio

How to Connect Blender’s Defocus Node to Camera Focus Settings and the Depth Pass

Connect the Render Layers node’s Image output to Defocus’s Image input and its depth output to Defocus’s Z input. Leave No Z-buffer disabled, select the matching scene, and set the focus distance on that scene’s camera. Adjust blur strength with the Defocus node’s own F-Stop. Blender documents this camera-based focus workflow in its Defocus Node manual.

This guide uses Blender 4.5 LTS terminology and follows one task: adding adjustable depth-of-field blur to an existing scene render. A three-object test will help you confirm that the intended subject stays sharp and that changing camera focus moves the sharp region correctly.

1. Understand which setting controls each part of the effect

The setup combines three kinds of information: the rendered picture, the distance to visible surfaces, and the camera’s focus settings. The Z pass supplies distance to the nearest visible surface; the camera specifies the focal distance; Defocus uses these inputs to simulate depth of field after rendering. See Blender’s Passes documentation and Defocus documentation.

Keep the controls separate while testing:

Control What you use it for
Camera Focus Object or focal distance Choose where the image should be sharp
Defocus F-Stop Adjust how strongly out-of-focus regions blur
Defocus Bokeh Type Choose the blur shape
Defocus Max Blur Limit the maximum blur radius
Camera focal length Set the camera’s field of view

The camera’s aperture controls and Defocus’s controls belong to separate rendering stages. Make compositor adjustments on the node itself. Also distinguish focal length from focal distance: Blender’s camera manual describes focal length as controlling field of view, while focal distance determines the focus location. Cameras — Blender Manual

2. Enable the Z pass on the correct view layer

Open View Layer Properties, expand Passes, and enable Z under the data passes. Render again after enabling it so the render result contains the required depth information. In Blender 4.5, the pass is called Z; other documentation versions may call it Depth. Its purpose is to record surface distance for effects such as Defocus. Passes — Blender Manual

In the Compositor, check the Render Layers node’s Scene and View Layer selections. Enable the pass on that selected view layer. Render Layers exposes additional output sockets for enabled passes, so a missing depth socket is a reason to check the layer selection and pass settings before adjusting blur. Render Layers Node — Blender Manual

For the initial test, use a sharp base render without camera-rendered depth of field or motion blur. This makes the compositor’s contribution easier to judge. Blender also notes that the Z pass can produce noisy results when the render itself uses either effect. Passes — Blender Manual

Use a full render for this first check, especially with Cycles. Blender 4.5’s viewport compositor only provides render-pass outputs with EEVEE; other engines produce empty pass outputs there. A viewport limitation can therefore resemble a broken node connection. Render Layers Node — Blender Manual

3. Connect the image and depth paths

Open the Compositing workspace, enable Use Nodes if needed, and add a Defocus node. Build this connection layout; it is a wiring reference, not executable code:

Render Layers: Image → Defocus: Image
Render Layers: Depth → Defocus: Z
Defocus: Image       → Composite: Image

Use the Render Layers depth output available in your version; the pass checkbox in Blender 4.5 is named Z. You can also connect Defocus’s image output to a Viewer node for inspection.

On Defocus, leave No Z-buffer unchecked and set its Scene selector to the scene supplying the render. The node accepts both true depth data and grayscale masks, but those are different operating modes. With No Z-buffer enabled, the input directly controls blur radius through Z Scale, and F-Stop becomes inactive. Defocus Node — Blender Manual

For this camera-linked workflow, feed depth directly into Z. Avoid inserting a Normalize node or Color Ramp into that connection: remapping distance into a display-friendly range changes the numerical relationship you are trying to preserve. If you want to inspect a remapped depth image, make a separate viewing branch and retain the direct depth connection to Defocus.

4. Set the camera’s focus location

Select the camera used by the rendered scene and open its Camera Data Properties. Under Depth of Field, choose either a numeric focal distance or a Focus Object. Blender disables the numeric distance control when a focus object is assigned. Cameras — Blender Manual

For a still image, use the distance eyedropper to sample the surface you want sharp. For a focus target you can position independently, add an Empty at the intended detail and select it as the camera’s Focus Object. Placing the target deliberately avoids relying on the origin of a large object when you actually want its front surface in focus.

Enable the camera’s Viewport Display limits to see the focus-distance marker. The manual describes a yellow cross representing the focus distance, which is useful when checking the setup from a side view. The camera documentation also explains the distance picker. Cameras — Blender Manual

If you temporarily enable camera depth of field to edit its settings, return to a sharp base render for the compositor test. Keep the focus target or stored distance set. Then adjust Defocus’s F-Stop separately. Start with an illustrative value such as 8, then try 4 if the difference is too subtle. Lower node values increase blur; the documented default of 128 represents an effectively all-in-focus result. Defocus Node — Blender Manual

5. Verify the connection with a three-object scene

Use this original test arrangement before judging a complex composition. Place a small orange cube near the camera, a blue cylinder farther back, and a green sphere beyond it. Offset them sideways so each silhouette remains visible. Add ordinary lighting and use a perspective camera framing all three objects.

For an illustrative scene, place their centers at approximately 3, 6, and 10 Blender units along the camera’s viewing direction. These are setup suggestions, not measured results. Give the objects enough depth separation to make focus changes visible, and place the focus Empty on the cylinder’s visible front surface rather than assuming its center is the intended detail.

Run the following checks in order:

  1. Establish the baseline. Bypass Defocus and confirm that all three objects have readable edges.
  2. Focus on the cylinder. Restore Defocus and position the focus target on the cylinder. Its target area should retain more detail than the separated foreground and background objects.
  3. Change blur strength. Keep focus fixed and lower the node’s F-Stop. Look for stronger blur away from the target.
  4. Move the focus target. Place it on the sphere and render again. The sharpest region should move toward the sphere.
  5. Inspect at output size. Examine the cylinder and sphere edges at 100% rather than judging only a reduced preview.

This sequence separates two questions: whether the node produces blur and whether it follows the intended camera focus. If changing F-Stop works but moving the target does not, check the selected scene, rendered camera, and focus assignment. If neither change works, check the output connection, depth pass, and No Z-buffer state before refining the appearance.

6. Diagnose flat blur, missing blur, and rough edges

Use the visible symptom to decide what to inspect next:

Symptom First checks
Everything looks sharp Lower Defocus’s F-Stop; confirm its output reaches Composite; verify depth separation
Everything looks similarly blurred Check focus distance and confirm that unmodified depth reaches Z
Node F-Stop is inactive Disable No Z-buffer for the depth-pass workflow
Blur appears capped Inspect Max Blur; a positive value limits radius
The wrong object stays sharp Check Focus Object, camera selection, and Defocus’s scene selection
Pass works in a render but not the viewport Check Blender 4.5’s viewport render-pass support

Blender documents Max Blur = 0 as having no radius limit. A positive cap can keep a preview manageable, but it can also conceal the difference between two strong blur settings. Change one control at a time so you can identify which adjustment affects the result. Defocus Node — Blender Manual

Rough silhouettes need a different diagnosis. Blender’s Z pass is not anti-aliased, and the Defocus manual describes edge artifacts and stair-stepping at low f-stop values. First raise the node’s F-Stop and inspect again. For a demanding still, the manual also suggests rendering at twice the intended dimensions and scaling down. Treat that as an edge-quality technique, not a repair for incorrect depth connections. Passes, Defocus Node

7. Decide when compositor defocus is sufficient

Defocus is useful when you want to adjust depth-based blur after producing the image and Z pass. Its limitations become visible where a strongly blurred foreground object overlaps a detailed background. A single rendered image does not contain all the background detail hidden behind that foreground object; the Defocus manual explicitly describes this limitation of its post-processing approach. Defocus Node — Blender Manual

For an overlapping arrangement, compare a small camera-rendered depth-of-field test before committing to compositor blur. Another option documented by Blender is to render foreground and background separately and process them independently. That requires additional compositing work, so reserve it for an overlap that materially affects the picture.

Keep the setup once it passes two practical checks: adjusting Defocus’s F-Stop changes blur strength, and moving the camera’s focus target changes which subject remains sharp. Then judge the final image at its intended size, paying particular attention to the chosen detail and overlapping silhouettes.

Sources