Expand description
Wisp - interactive WGSL shaders for Bevy.
A wisp is a plain .wgsl file describing a (possibly multi-pass) fullscreen
shader. There is no external metadata: the shader’s own interface is reflected
via naga. Members of its params uniform struct become tweakable inputs, ///
doc-comment annotations supply defaults, ranges and pass configuration, and
each @fragment/@compute entry point becomes a pass.
struct Globals {
resolution: vec2<f32>,
time: f32,
}
@group(0) @binding(0) var<uniform> globals: Globals;
struct Params {
/// Overall strength of the effect.
/// @min(0.0) @max(1.0) @default(0.5)
level: f32,
/// @color @default(1.0, 0.0, 0.0, 1.0)
tint: vec4<f32>,
}
@group(1) @binding(0) var<uniform> params: Params;
@fragment
fn fragment(@location(0) uv: vec2<f32>) -> @location(0) vec4<f32> {
return params.tint * params.level * sin(globals.time);
}Add WispPlugin to the app, load a wisp with
asset_server.load::<Wisp>("path.wgsl") and insert a
WispHandle on a camera; the shader renders wherever the
camera does. Tweak inputs through the camera’s WispInputs
component.
See schema for the full set of conventions and annotations, globals for
the recognized globals members, and asset for how loading works.
Wisp grew out of nannou’s nannou_isf (an implementation
of the Interactive Shader Format) and is the modern, WGSL-first successor to
that idea.
Modules§
- annot
- Parsing of
///doc-comment annotations. - asset
- The
Wispasset and its loader. - error
- Live error reporting for wisp shaders.
- globals
- The wisp-provided globals uniform: recognized member names, layout packing and a date helper.
- inputs
- Runtime values for a wisp shader’s inputs.
- prelude
- reflect
- WGSL parsing, validation and analysis via
naga. - render
- Render-world plumbing: pipeline specialization, uniform packing and the fullscreen pass.
- schema
- The reflected interface of a wisp shader.
- targets
- Per-camera management of intermediate pass-target images.
Structs§
- Wisp
Config - Behavioural configuration for
WispPlugin. Insert before adding the plugin to override the defaults. - Wisp
Plugin