Shadertools
Overview
@luma.gl/shadertools assembles reusable shader behavior. It resolves module dependencies,
typed props and bindings, hooks, injections, plugins, and passes into shader source. It does
not create a device or compile shaders itself.
The generated Shadertools API index at /docs/api-reference/generated/shadertools contains every
public descriptor, helper, built-in module, and type with source links.
When to use it
Use Shadertools when shader behavior must be shared, configured, or composed. Use plain WGSL or GLSL for a tiny one-off shader. Move up to Engine when the assembled shader needs geometry, inputs, a pipeline, and draw lifecycle management.
Live example
Toggle the module behavior in the running example and compare the reusable module inputs with the assembled WGSL/GLSL application that Engine submits.
- Dependencies
- color → lighting
- Hook
fragmentColor(baseColor)- Injection
- lighting::shade
- Uniforms
- lighting.intensity
Assembled teaching source
// module: color
fn applyColor(base: vec3<f32>) -> vec3<f32> { return base; }
// module: lighting
fn shade(base: vec3<f32>) -> vec3<f32> { return applyColor(base) * 0.85; }Core concepts
- shader moduleReusable shader behavior with source, dependencies, typed props or bindings, and optional injection points.
- Reusable shader behavior with source, dependencies, typed props or bindings, and optional injection points.
- bindingThe connection that makes a buffer, texture, sampler, or uniform block available to shader code.
- The connection that makes a buffer, texture, sampler, or uniform block available to shader code.
- hookA named extension point in shader source that modules or plugins may call or implement.
- A named extension point in shader source that modules or plugins may call or implement.
- injectionShader source inserted at a declared hook or source location during assembly.
- Shader source inserted at a declared hook or source location during assembly.
- pluginA configurable shader extension that selects modules, bindings, and source changes for a rendering feature.
- A configurable shader extension that selects modules, bindings, and source changes for a rendering feature.
- pipelineCompiled shader stages plus fixed GPU state used for rendering or compute work.
- Compiled shader stages plus fixed GPU state used for rendering or compute work.
The learning spine is: modules and dependencies; uniforms and bindings; hooks and injections; assembly; plugins and passes; portability; then the built-in module and pass catalogs.
Feature card
Workflows
- Learn the workflowBuild the mental model before choosing classes.
- Copy a focused recipeStart from a complete, small task.
- Check the complete APIConfirm exact types, defaults, and ownership.
The Shadertools cookbook covers authoring modules, exposing props, adding hooks, injecting source, composing dependencies, creating plugins, and defining passes.
API index
Composable shader modules, dependencies, hooks, injections, plugins, passes, and portable assembly.
- Modules and dependencies
- Props and bindings
- Hooks and injections
- Assembly
- Plugins and passes
- Portability and catalogs
The generated Shadertools API index is the exhaustive, source-linked inventory of every public value and TypeScript export. The curated pages explain how the related families fit together.
Keep the shader module catalog and shader pass catalog separate from the teaching path; use them after choosing the relevant descriptor family.
Limits and compatibility
- A module may provide WGSL, GLSL, or both. The selected backend requires a compatible source path.
- Shadertools assembles text and metadata; Core adapters perform validation and compilation.
- Dependency order is deterministic, but conflicting hook or binding contracts remain author errors.
- Plugins should state their source, binding, and backend requirements explicitly.