Uniform reference
Every shader receives the same built-in slots plus one slot per declared
uniform — always vec4, packed identically on WebGPU and WebGL2, so a
single buffer upload covers the whole frame.
Built-in slots
Section titled “Built-in slots”| Slot (WGSL / GLSL) | Contents |
|---|---|
uni.time / u_time |
x elapsed seconds (performance.now()-based), y clamped dt, zw unused |
uni.resolution / u_resolution |
xy canvas size in pixels, zw unused |
uni.mouse / u_mouse |
xy smoothed pointer uv, zw raw target |
uni.pointer / u_pointer |
xy pointer velocity (~uv/s), z hover 0→1, w pressed 0/1 |
uni.pulse / u_pulse |
xy last press uv, z ring strength decaying 1→0, w press age (s) |
uni.scroll / u_scroll |
x element viewport progress 0→1, y damped scroll velocity (viewport-heights/s) |
mouse, pointer, and pulse only update when the instance is created
with pointer: true. See Interactions.
Declared uniforms
Section titled “Declared uniforms”Each key in ShaderDefinition.uniforms becomes uni.<name> /
u_<name>:
uniforms: { speed: { size: 1, default: 0.35 }, // read as uni.speed.x tint: { size: 3, default: [...] }, // read as uni.tint.xyz}size is the component count actually used — the storage slot is still
a full vec4. Scalars read from .x, colors from .xyz.
Post-processing channels
Section titled “Post-processing channels”Two conventional slots reserved for post effects; the element and styles registry treat them as part of every preset:
| Uniform | Channels |
|---|---|
postfx |
[grain, vignette, posterize, scanline] |
postfx2 |
[hue shift, contrast, brightness, invert] |
On <sk-shader> they’re settable like any other uniform:
<sk-shader style="aurora-mono" postfx="[0.02, 0.6, 0, 0]"></sk-shader>Packing rules
Section titled “Packing rules”- One
vec4slot per field — no sub-vec4 packing, no padding surprises. - Values you don’t set keep defaults: engine default < preset < explicit.
updateUniforms({ key })rewrites only the fields you pass.- Numbers and
number[]both accepted; arrays takesizecomponents.