DOF

Read with AI
All docs in one file (llms-full.txt)
DOF #Fx #Node
DOF

A depth-of-field node that computes the circle of confusion (CoC) from a depth texture and mixes a blurred image with a sharp one. The CoC is saturate(|linear depth - Focus Distance| / Focus Range), so the further from the focal plane, the more blurred it gets. The processing is three passes: a 1/2 resolution downsample with CoC, one round trip of separable blur, then compositing.

  • Focus Distance — the focus distance. Initial value 30. Guarded at a minimum of 0.01 (Focus Distance input / focusInput)
  • Focus Range — the CoC reaches its maximum at this distance away. Initial value 10. Guarded at a minimum of 0.001 (Focus Range input / rangeInput)
  • Blur Strength — a multiplier for the blur sample spacing. Initial value 2. Negative values are treated as 0 (Blur Strength input / blurInput)
  • Camera — its near/far are used to reconstruct linear depth

If Depth Texture is not connected, the input passes through unchanged. Connect the depth output of a Render node.

When the Camera input is not connected (or is invalid), it falls back to the default camera values (near=0.1 / far=1000). If the actual camera’s near/far differ from these, the Focus Distance number and the actual focal position will not match.

When compositing, the larger of its own CoC and the CoC on the blurred side is used, so foreground blur bleeds out over the background.

The output alpha is always fixed at 1. Removing the In input clears the output to black.

The output supports HDR, and its resolution is the same as the input.

Input ports

Port IDType
Render TextureRenderTexture
Depth TextureRenderTexture
CameraCameraDataInput
Focus Distancefloat
Focus Rangefloat
Blur Strengthfloat

Output ports

Port IDType
Render TextureRenderTexture

Scriptable members

PathType
focusInputfloat
rangeInputfloat
blurInputfloat

Synapse Apps (scripting)

await synapse.modules.create({ type: "DOF" })

Also referenced from