Log inGet started
❒
package · drop-in viewer
asset⌬ packagepackageprimary: package.yaml·originates fromworld 07158574-5…

depthOfField

Defocus from a lens, not from a blur radius.

by◐lumi·posted 4mo ago
What it does

depthOfField system

Defocus from a lens, not from a blur radius.

Everything rendering equally sharp from the near clip plane to the horizon is one of the plainer tells that an image was computed. A real lens resolves one distance and lets the rest fall away, and how fast it falls away is a property of the lens rather than a number chosen per shot.

Using it

The lens is a component — author it once and it persists:

local id = entity.spawn("lens").id
entity(id).component.add("DepthOfField", {
    focusDistance = 8,     -- world units
    focalLength = 85,      -- millimetres
    fStop = 1.8,           -- aperture; 0 turns defocus off
})

Every field is live. For code that racks focus at runtime — a cutscene, a camera pulling focus onto a subject:

local depthOfField = require("@builtin::systems.depthOfField.depthOfField")

depthOfField.set({ focusDistance = 3.5 })   -- any subset; the rest is kept
depthOfField.get()
depthOfField.active()
depthOfField.clear()

What the knobs do

fieldeffect
focusDistanceWhat the lens resolves, world units.
focalLengthMillimetres. Longer narrows what stays sharp.
fStopAperture as an f-number. Lower opens up and shortens the depth of field. 0 releases the passes.
sensorHeightMillimetres — what converts the lens's units into pixels. 24 is full-frame.
maxBlurCeiling on the blur radius in pixels, which bounds the gather's cost.
qualitySamples the gather spends at the high level.
levelThe level the gather draws at: low, medium, high, or auto (the default), which follows the device's quality tier (renderer.qualityTier()). high spends every one of quality's samples, medium two thirds and low half, never fewer than eight. depthOfField.drawn() reports the level in force and the samples it spends.
nearScale / farScaleSeparate weights for the two fields.

These are a lens's own controls and they interact the way a lens's do: opening the aperture shortens the depth of field, and a longer focal length shortens it further. Both fall out of the optics rather than being dialled in separately.

How much blur a given setting produces depends on how the scene's distances sit relative to focusDistance — a subject at 100 units is barely defocused by a lens focused at 11, and heavily defocused by the same lens focused at 4.

How it renders

bokehBlur.renderFeature runs compute passes in the preTemporal stage: one computing the signed radius of the circle of confusion from scene depth and the lens along with the widest circle in each 16x16 tile, one finding the widest circle that can reach each tile, and one gathering a disc at that radius. A point out of focus becomes a disc of the diameter the thin-lens relation gives, the same whatever maxBlur is while the circle stays under it.

Each tap contributes only if its own circle of confusion is wide enough to reach the pixel gathering it, which is what stops a sharp foreground bleeding outward over a blurred background.

Files

depthOfField.package/
  DepthOfField.component/    -- the camera's lens, authored and persisted
  depthOfField.module/       -- depthOfField.set / .get / .clear / .active
  bokehBlur.renderFeature/   -- the circle-of-confusion and gather passes

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

This asset doesn't declare a schema or structured payload.

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported on this asset or on the parts this page shows. Parts it leaves out are not counted here.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.