Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite09f1e4457

README.md

DepthOfField

The camera's lens, as a component.

local id = entity.spawn("lens").id
entity(id).component.add("DepthOfField", {
    focusDistance = 8,
    fStop = 1.8,
    focalLength = 85,
})

The scene stops being uniformly sharp: what sits at the focus distance stays crisp and everything else falls off the way an aperture makes it.

The knobs are a lens's own, and the relationships between them come out of the optics rather than being dialled in separately — opening the aperture shortens the depth of field, a longer focal length shortens it further. A setting that reads like a real lens behaves like one.

Every field is live. An fStop of 0 releases the passes entirely.

maxBlur bounds the gather's radius in pixels, and quality its sample count.

For code that racks focus at runtime, reach for @builtin::systems.depthOfField.depthOfField.

The full description is in the package readme: guides { path = "systems/depthOfField" }.