bokehDefocus

A photographic lens blur where bright highlights bloom into aperture-shaped discs.

bokehDefocus(opts: {
    radius: PropRef
    gain: PropRef
    threshold: PropRef
    shape: PropRef
    blades: PropRef
    rotation: PropRef
    fringe: PropRef
}): {compute: GpuComputeNode; gpu: {fragment: (params: GpuFragmentParams) => Expr}}

Import effects from shaders/std and use effects.blurs.bokehDefocus.

radius (0–100) is the defocus; 100 is a disc about 80 pixels across. gain (0–10) is how strongly highlights bloom and threshold (0–1) the brightness they must pass. shape is a string prop: 'blades' | 'circle' | 'star' | 'heart' | 'flower' | 'cross' | 'ring'. blades (0–9) counts blades or points for the blades, star and flower shapes; 0–2 is a round iris. rotation is in degrees and fringe (0–1) adds color fringing at the disc edges. Both color and coverage blur, so silhouettes soften like a real lens. Changing the aperture never recompiles. Spread it into a definition with species: 'custom', requiresRTT: true and requiresChild: true.

Parameters

NameTypeNotes
opts`{
radius: PropRef
gain: PropRef
threshold: PropRef
shape: PropRef
blades: PropRef
rotation: PropRef
fringe: PropRef

}` | |

Example

...bokehDefocus({radius: p('radius'), gain: p('highlightGain'), threshold: p('highlightThreshold'), shape: p('bladeShape'), blades: p('bladeCount'), rotation: p('bladeRotation'), fringe: p('chromaticFringe')})

See also

  • gaussianBlur — A soft, even blur of the child.
  • tiltShift — Keeps a band of the child in focus and blurs everything beyond it, like a tilt-shift lens.
  • bloom — A glow: the child's bright parts spread into a soft halo that adds back on top.

Used by

BokehBlur