starGlint

A four-point star of light: a round core with a thin ray along each axis, like a glint off glitter or a star in a photograph.

starGlint(offset: Expr, opts: {
    core: Expr | number
    rayLength: Expr | number
    rayWidth: Expr | number
    rays: Expr | number
    /** Optional: the glint fades to nothing by this distance from its centre (measured along the larger axis). */
    reach?: Expr | number
}): Expr

Import light from shaders/std and use light.starGlint.

offset is the pixel's position relative to the star's centre, as a vec2, in whatever unit you measure the star in (CSS pixels suit small glints). Returns the brightness: 1 at the centre, falling off along the rays and faster everywhere else. core is the core's sharpness (larger is a smaller dot). rayLength and rayWidth are falloff rates along and across each ray (smaller rayLength is a longer ray). rays is the rays' brightness relative to the core.

Parameters

NameTypeNotes
offsetExpr
opts`{
core: Expr \| number
rayLength: Expr \| number
rayWidth: Expr \| number
rays: Expr \| number
/** Optional: the glint fades to nothing by this distance from its centre (measured along the larger axis). */
reach?: Expr \| number

}` | |

Example

const glint = starGlint(offset, {core: 0.9, rayLength: 0.45, rayWidth: 1.6, rays: 0.25})

Tip. Multiply by a flashes blink for a sparkle that comes and goes. Set reach to half the cell size when the glints sit on a scatterPoints grid, so long rays never hit a cell edge.

See also

  • glowSpot — A soft oval glow over an offset you have already scaled, the core of a bloom or a glare.
  • raySpikes — Thin star spikes with dark gaps between them, like light through a camera aperture.
  • flareStarburst — The star of thin spikes around the light in a lens flare.

Used by

Sparkle