Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit7b5db6af39

README.md

depthOfField

Depth of field from a lens.

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

depthOfField.set({ focusDistance = 8, fStop = 1.8, focalLength = 85 })
depthOfField.get()      --> the lens in force
depthOfField.active()   --> are the passes running
depthOfField.clear()    --> defocus off, lens kept

set takes any subset, so a rack focus is one field. An fStop of 0 turns defocus off and releases the passes.

The knobs are a lens's own, and the relationships between them come out of the optics: opening the aperture shortens the depth of field, a longer focal length shortens it further. sensorHeight is what converts the lens's millimetres into pixels — 24 is full-frame.

nearScale and farScale weight the two fields separately, for a look that wants one without the other.

For a lens a scene should simply have, author the DepthOfField component instead. This module is for code that racks focus at runtime — a cutscene, a camera pulling focus onto a subject.

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