dot

The dot product of two vectors.

dot(a: Val, b: Val): Expr

Import math from shaders/std and use math.dot.

With two unit vectors it is the cosine of the angle between them, which is how a light direction meets a surface normal.

Parameters

NameTypeNotes
aVal
bVal

Example

const facing = max(dot(normal, lightDir), 0)

See also

  • normalize — The vector scaled to length 1.
  • cross — The cross product of two 3D vectors.

Used by

CarbonFiber, Crystal, Frost, Goo, Heatmap, Holographic, Irradiance, Nebula, PixelThrow, Plastic, ReactionDiffusion, Sparkle, TimeTrail, Voxels, Water