clamp

The value limited to the range lo..hi.

clamp(x: Val, lo: Val, hi: Val): Expr

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

Parameters

NameTypeNotes
xVal
loVal
hiVal

Example

const alpha = clamp(add(body, ring), 0, 1)

See also

  • min — The smaller of two values.
  • max — The larger of two values.

Used by

Aurora, BrushedMetal, CarbonFiber, Chrome, CompressionArtifacts, Crystal, FlowingGradient, Frost, Goo, Heatmap, Hologram, Holographic, InkFlow, LiquidMetal, MeshGradient, Nebula, PixelThrow, Plastic, Prism, ReactionDiffusion, SmokeFill, StudioBackground, Surface3D, Voxels, Water, Waveform