Skip to main content

Module shader

Module shader 

Expand description

A theme’s own surface shader: a short WGSL function a finish names, validated when the theme is read (docs/architecture/theming.md, “A surface shader”).

A theme may paint a surface role with its own colour arithmetic instead of choosing from the built-in painter sets: ordered dithering, pixelation, a hatch, a gradient the palette roles cannot express. The shader is one pure function over a fixed, documented set of inputs (INPUTS), declaring no entry point and no bindings of its own — the toolkit writes the pipeline around it — so it cannot sample anything but what the toolkit samples for it, cannot read the person’s data or the window’s content, and has no clock: time is the static value the theme states.

It runs once per settled frame: the toolkit evaluates it into the surface’s image when the surface, its theme or what the surface samples changes, and replays that image until then, so an idle surface draws no frame.

The source is checked when the theme is read (Source::validate): it must parse as WGSL, declare exactly one function fs_surface whose parameters and result are exactly INPUTS, and declare no entry point and no global. A theme that fails is refused, with the reason, and the theme it sits on does not apply.

Structs§

Source
A surface shader as a theme document states it.

Constants§

ENTRY
The function a surface shader must declare.
FINISH_PARAMS
The finish parameters a shader may read, as params.xyzw.
INPUTS
What a surface shader may read, in the order it must take them: the parameter’s name and type in WGSL, and what it holds. Every colour is linear sRGB with alpha last.
MAX_SOURCE
The most source a theme may carry, bytes. A surface shader is a few dozen lines; anything longer is a program, not a look.
RESULT
The result every surface shader returns: an opaque or translucent colour for the fragment (alpha last). The toolkit holds what it paints inside the material’s legibility band, so a shader cannot break ink’s contrast.

Functions§

check
Check that wgsl is a surface shader of the documented shape, and name what is wrong when it is not.
wrap
The complete WGSL module the toolkit compiles: the pipeline around the theme’s fs_surface.