pointStars
A plane of sparse glinting points: stars, glitter, dust.
pointStars(p: Expr, opts: {
/** Frequency of the per-point variation field relative to `p` (slow, about 0.1). */
variationFreq: number
/** Point radius as `[base, jitter]`: base plus variation times jitter. */
radius: [number, number]
/** The band of the variation field that keeps a point at all. Narrower is sparser. */
keep: [number, number]
/** Brightness as `[base, gain]`: base plus variation squared times gain. */
brightness: [number, number]
/** A per-point shimmer factor built from the variation field (see `twinkle`). */
shimmer?: (variation: Expr) => Expr
/** Overall gain. */
gain: Expr
/** Color the glints: variation mixes `from` to `to`, scaled by the glint times `gain`. */
tint?: {from: [number, number, number]; to: [number, number, number]; gain: number}
hint?: string
}): {glint: Expr; variation: Expr; rgb?: Expr}
Import materials from shaders/std and use materials.pointStars.
p is the plane coordinate; scale it to set density. Returns the glint intensity, the slow per-point variation field, and rgb when tint is given. Radii are in the cellular noise's squared-distance units, so they are small (0.004–0.02).
Parameters
| Name | Type | Notes |
|---|---|---|
p | Expr | |
opts | `{ |
/** Frequency of the per-point variation field relative to `p` (slow, about 0.1). */
variationFreq: number
/** Point radius as `[base, jitter]`: base plus variation times jitter. */
radius: [number, number]
/** The band of the variation field that keeps a point at all. Narrower is sparser. */
keep: [number, number]
/** Brightness as `[base, gain]`: base plus variation squared times gain. */
brightness: [number, number]
/** A per-point shimmer factor built from the variation field (see `twinkle`). */
shimmer?: (variation: Expr) => Expr
/** Overall gain. */
gain: Expr
/** Color the glints: variation mixes `from` to `to`, scaled by the glint times `gain`. */
tint?: {from: [number, number, number]; to: [number, number, number]; gain: number}
hint?: string
}` | |
Example
const stars = pointStars(mul(pat, 40), {variationFreq: 0.13, radius: [0.004, 0.013], keep: [0.35, 0.75], brightness: [0.3, 1.2], gain: u.stars, tint: {from: [0.72, 0.82, 1], to: [1, 0.92, 0.82], gain: 1.6}})
See also
twinkle— A brightness factor that shimmers over time, different for each element.cellNoiseAt— Cellular noise at a 2D point: 0 at each cell's seed point, rising toward the cell walls.