brightestNear

The brightest color in a small ring around a point: the layer grown outward, so a spot just outside a bright area still reads as bright.

brightestNear(read: (uv: Expr) => Expr, center: Expr, opts: {radius: Expr; taps: number; angle?: number}): {
    color: Expr
    luma: Expr
}

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

read samples the layer at a uv and returns straight color (pass params.sampleStraight). center is the uv to look around; radius is the ring's radius per axis in uv, as a vec2 (divide a pixel radius by the viewport size). taps points sit evenly round the ring starting at angle degrees, plus the centre itself. Returns the brightest of them as color (straight) and its brightness as luma (Rec.709 luminance times alpha).

Parameters

NameTypeNotes
read(uv: Expr) => Expr
centerExpr
opts{radius: Expr; taps: number; angle?: number}

Example

const {color, luma} = brightestNear(params.sampleStraight, pointUV, {radius: div(p, viewport), taps: 4, angle: 45})

Tip. Thin bright details smaller than the gap between taps can slip through; more taps close the gaps at one sample each.

See also

  • gatherStack — Assemble an effect from one sampling stage and an ordered list of overlay stages.

Used by

Sparkle