inverseSquare

How a point light fades with distance: 1 at the source, half at range.

inverseSquare(distance: Expr, range: Expr | number): Expr

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

Parameters

NameTypeNotes
distanceExpr
rangeExpr | number

Example

const lit = mul(lambert(n, onBody.L), inverseSquare(onBody.distance, u.lightRange))

See also

  • pointLightFrom — A point light as seen from a point on the shape: the 3D light vector L, the 2D direction toLight and the distance.
  • lambert — How much a light falls on a surface: 0 facing away, 1 facing it.

Used by

Irradiance