@shadekit/shaders
One file per effect. Each exports a ShaderDefinition — the same object
ShaderInstance, <sk-shader>, and <Shader> all consume.
Importing an engine
Section titled “Importing an engine”// per-engine import — bundlers drop everything elseimport { aurora } from '@shadekit/shaders/aurora';
// or from the index when you want severalimport { aurora, nebula, glitch } from '@shadekit/shaders';sideEffects: false on the package means a per-file import keeps your
bundle to exactly the engines you name.
The styles registry
Section titled “The styles registry”import { styles, styleCount, styleNames, styleCollections } from '@shadekit/shaders';// or just the registry: '@shadekit/shaders/styles'| Export | Type | Description |
|---|---|---|
styles |
Record<string, ShaderStyle> |
179 named presets — { shader, uniforms } each |
styleCount |
number |
Total presets in the registry |
styleNames |
string[] |
Every preset key |
styleCollections |
Record<string, string[]> |
Curated subsets: mono, ember, abyss, neon |
A ShaderStyle is a named preset — one engine plus a uniform set:
styles['aurora-ember'];// { shader: 'aurora', uniforms: { speed: 0.45, intensity: 1.1, colors: [0.92, 0.38, 0.2] } }Naming is <engine>-<name>. Presets power <sk-shader style="..."> —
see <sk-shader> element.
Writing your own shader
Section titled “Writing your own shader”A ShaderDefinition needs both backends — identical uniform packing
keeps them interchangeable:
import type { ShaderDefinition } from '@shadekit/core';
export const myShader: ShaderDefinition = { name: 'my-shader', // unique — keys the shared pipeline cache uniforms: { speed: { size: 1, default: 0.5 }, tint: { size: 3, default: [0.4, 0.8, 1.0] }, }, wgsl: /* wgsl */ ` @fragment fn fs_main(in: VertexOutput) -> @location(0) vec4f { let t = uni.time.x * uni.speed.x; return vec4f(uni.tint.xyz * (0.5 + 0.5 * sin(t)), 1.0); } `, glsl: /* glsl */ ` void main() { float t = u_time.x * u_speed.x; o_color = vec4(u_tint.xyz * (0.5 + 0.5 * sin(t)), 1.0); } `,};- WGSL must define
@fragment fn fs_main(in: VertexOutput) -> @location(0) vec4f. - GLSL ES 3.00 must define
void main()writingo_color. - Built-ins:
uni.time/u_time,uni.resolution/u_resolution,uni.mouse/u_mouse,uni.pointer/u_pointer,uni.pulse/u_pulse,uni.scroll/u_scroll— allvec4slots, same packing. - Your
uniformskeys becomeuni.<name>/u_<name>slots.
See Uniform reference for the slot contents and Shader catalog for what ships.