local

A value computed once per pixel and shared by everything that reads it.

local(e: Expr, hint: string): Expr

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

Wrap any expression you use twice or more. hint is a short name that appears in the generated code and only has to be readable.

Parameters

NameTypeNotes
eExpr
hintstring

Example

const dist = local(length(sub(uv, params.uniforms.center)), 'dist')

Tip. Without it, the same math is repeated at every place you use the value.

Used by

Aurora, Blob, BrushedMetal, CarbonFiber, Chrome, CompressionArtifacts, Crystal, FlowingGradient, Frost, Goo, Heatmap, Hologram, Holographic, InkFlow, Irradiance, LiquidMetal, Marble, MeshGradient, Nebula, Obsidian, PixelThrow, Plastic, Prism, ReactionDiffusion, Sparkle, StudioBackground, Surface3D, TimeTrail, Voxels, Water, Waveform