Log inGet started
Package

DepthOfField.component

Newest version

This package holds more than this page lists. See all of its files in its world.

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 at the high level. level is the level the gather draws at: low, medium, high, or auto (the default), which follows the device's quality tier (renderer.qualityTier()); medium spends two thirds of the samples and low half.

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" }.