lensGhost
One ghost disc of a lens flare, the faint circles that line up across from the light.
lensGhost(slots: {intensity: ArgSpec; spread: ArgSpec; chroma: ArgSpec}): (flare: Expr, disc: [number, number, number, number], tint: [number, number, number, number], params: GpuFragmentParams) => Expr
Import light from shaders/std and use light.lensGhost.
Call the result once per ghost with the flare frame, a disc and a tint, and sum the calls with additive. disc is [offset, size, brightness, hollow]: how far along the axis from the light (scaled by spread), radius in aspect-corrected uv, brightness, and 0–1 for a solid disc to a ring. tint is [r, g, b, phase], the color and a shimmer offset. chroma (0–1) adds a rainbow rim. Returns an RGB.
Parameters
| Name | Type | Notes |
|---|---|---|
slots | {intensity: ArgSpec; spread: ArgSpec; chroma: ArgSpec} |
Example
const ghost = lensGhost({intensity: p('ghostIntensity'), spread: p('ghostSpread'), chroma: p('ghostChroma')})
const ghosts = additive(ghost(flare, [0.15, 0.20, 0.30, 0.10], [1.0, 0.95, 0.90, 0.0], params), ghost(flare, [0.30, 0.12, 0.25, 0.65], [1.0, 0.85, 0.55, 2.17], params))
See also
flareFrame— The shared frame of a camera lens flare, which everyflare*part reads.additive— Adds lights together, since light from several sources simply sums.flareHalo— The rainbow halo ring of a lens flare, drawn across the canvas from the light.