div

The first value divided by the second.

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

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

Dividing by zero produces infinity on the GPU, so guard a prop with max first.

Parameters

NameTypeNotes
aVal
bVal

Example

const normalized = div(dist, max(params.uniforms.radius, 0.001))

See also

  • mul — The product of two values.
  • max — The larger of two values.

Used by

Aurora, CarbonFiber, Chrome, CompressionArtifacts, Crystal, FlowingGradient, Frost, Goo, Heatmap, Hologram, Holographic, Irradiance, Marble, MeshGradient, Plastic, Prism, ReactionDiffusion, Sparkle, StudioBackground, TimeTrail, Water, Waveform