<sk-wgsl-color-uniform>

← prev index next →

Feeds a colour into your custom WGSL shader as a named uniform — authored the way every Skenra colour is (color="#E0A85A", "coral", "rgba(…)") instead of four hand-converted linear-RGBA floats.

Remarks

This is the colour member of the shader-input family that belongs to the compute & custom-WGSL concept (AbstractComputeNode), and — modeled on ColorStop — it is itself a SkenraAnimatable. The authored colour string is parsed and linearised through the standard colour path, so the shader receives it in straight-alpha LINEAR RGBA (RGB through the inverse-sRGB transfer, alpha unchanged) — exactly the space custom-WGSL colour kernels expect. It packs as a single vec4<f32> reusing the vec4 ABI, so the generated accessor is skUniform_<name>() -> vec4<f32>; the author never hand-converts a colour to floats again.

Key attributes. name is a non-animatable WGSL identifier, unique per host — changing it (or adding/removing/reordering uniforms) re-keys the shader. color is the animatable colour: it accepts the CSS colour subset the Skenra parser supports (the four hex lengths, legacy comma rgb()/rgba() and hsl()/hsla(), the oklab() subset, named colours, and transparent) plus var(--…), is optional (an absent colour is a valid transparent uniform), and interpolates as straight-alpha linear-RGB — the standard colour-interpolation contract, not a raw per-component lerp. An invalid colour throws.

Related. It is a child of any custom-WGSL host — sk-custom-wgsl-color-source, sk-custom-wgsl-points-source, sk-custom-wgsl-point-constraint, sk-custom-wgsl-spline-source, or sk-compute-node. For a raw four-lane value use sk-wgsl-vec4-uniform; for other inputs see sk-wgsl-uniform, sk-wgsl-vec2-uniform, sk-wgsl-vec3-uniform, and sk-wgsl-f32-array-uniform.

Serve these docs to run the live example. WebGPU needs a secure context — open this page via grunt serve rather than double-clicking the file. The Markup tab works from disk.

Attributes

AttributeTypeDefaultDescription
id <id> The element's unique identifier — the standard HTML global id attribute.
namerequired <string> "" Gets the WGSL identifier this member is addressed by.
coloranimatable <color> Gets the colour, returning the animated value when animating.