throughSlab

Follow one ray through a transparent body: in through the front face, out through the back.

throughSlab(opts: {
    view: Expr
    front: Expr
    back: Expr
    ior: Expr
    thickness: Expr
    behind: Expr
    hint?: string
}): SlabPassage

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

view is the incoming direction, front the front face's normal (facing the viewer) and back the back face's normal turned inward (also facing the viewer). ior is the index of refraction, thickness the distance between the faces and behind how far past the back face the scene sits. Returns where the ray lands on the scene (landing), how much escapes (Fresnel at the back face, zero under total internal reflection), the exit and grazing measures, and the bounce: light the back face reflects back out through the front, the sparkle inside a gem. Light trapped at the front face too runs out along the surface, so the hand-off is seamless.

Parameters

NameTypeNotes
opts`{
view: Expr
front: Expr
back: Expr
ior: Expr
thickness: Expr
behind: Expr
hint?: string

}` | |

Example

const pass = throughSlab({view, front: nF, back: nB, ior, thickness, behind: u.backdrop})
const seen = mul(backdropAt(pass.landing), pass.escape)

See also

  • spectralSum — Light seen across the whole visible spectrum, added up slice by slice into one rgb colour.
  • roundedSlab — A flat shape's glass profile: a slab whose edge rounds over in a quarter circle.
  • beerLambert — How much light survives a thickness of tinted material, per channel.

Used by

PrismaticGlass