Core guide

Custom shader effects

Apply a constrained fragment effect while Squander owns GPU resources.

Live example

See Custom shader effects in action

Use a fixed fragment body and numeric uniforms to transform a sampled texture.

live rendering loading ticks 0

How it works

Effects run after texture sampling and tinting. The body can read color, normalized uv coordinates, and a four-vector uniform array; bindings, pipelines, and disposal remain private.

Public types

  • ShaderEffectOptions
  • WebGpuShaderEffect
  • TextureDrawOptions.effect

Minimum viable example

typescript
const effect = renderer.create_shader_effect({
  fragment_code: "return vec4f(color.rgb * uniforms[0].x, color.a);",
  uniforms: [0.75],
});
await renderer.draw_texture(texture, { effect });
effect.release();

Scope and limitations

Only texture and render-target draws are supported. Custom vertex code, arbitrary bindings, storage textures, mipmaps, and untrusted-source security guarantees are out of scope.