causticCast

The shadow and the focused light a transparent object throws on the surface behind it.

causticCast(sampleAt: (p: Expr) => Expr, opts: {
    at: Expr
    offset: Expr
    slant: Expr
    focus: Expr
    spread: Expr
    hint?: string
}): {shadow: Expr; light: Expr}

Import materials from shaders/std and use materials.causticCast.

sampleAt(p) returns the object's signed distance (negative inside) at a placement point; the object's centre is at (0.5, 0.5). at is this pixel's placement point, offset how far the light pushes the object's image across the surface (placement units), and slant the cosine of how steeply the light arrives (1 head-on; lower stretches everything along the offset). focus (0–1) is how tightly the object gathers the light into a bright spot, spread (0–1) how far its colours focus apart, fanning the spot's edge into a spectrum. Returns shadow (0–1: how much to darken the surface, open in the middle like a real glass shadow) and light (rgb multiplier on the light's colour for the caustic). Four taps of the field.

Parameters

NameTypeNotes
sampleAt(p: Expr) => Expr
opts`{
at: Expr
offset: Expr
slant: Expr
focus: Expr
spread: Expr
hint?: string

}` | |

Example

const cast = causticCast((p) => frame.sampler(p).member('x'), {at: frame.sdfUV!, offset, slant: K.member('z'), focus, spread: u.dispersion})

Tip. Only reads right when the layers beneath look like a lit surface (a wall, paper, a studio sweep).

See also

  • throughSlab — Follow one ray through a transparent body: in through the front face, out through the back.
  • beerLambert — How much light survives a thickness of tinted material, per channel.

Used by

PrismaticGlass