API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classWebGpuShaderFilter
A high-level Filter subclass that renders the input texture through a user-provided WGSL fragment shader on the **WebGPU** backend. For the WebGL2 backend use WebGl2ShaderFilter. ## Usage ```ts const filter = new WebGpuShaderFilter({ fragmentSource: ` @group(0) @binding(0) var<uniform> uResolution: vec2<f32>; @group(0) @binding(1) var uTexture: texture_2d<f32>; @group(0) @binding(2) var uSampler: sampler; @fragment fn main(@location(0) vUv: vec2<f32>) -> @location(0) vec4<f32> { return textureSample(uTexture, uSampler, vUv); } `, uniforms: { uTime: 0.0 }, }); // Update uniforms each frame: filter.uniforms.uTime = performance.now() / 1000; sprite.filters = [filter]; ``` ## Auto-bound uniforms (group 0) - `@binding(0)` — `var<uniform> uResolution: vec2<f32>` (output dimensions) - `@binding(1)` — `var uTexture: texture_2d<f32>` (filter input) - `@binding(2)` — `var uSampler: sampler` ## User uniforms (group 1) All non-texture user uniforms are packed into a single uniform buffer at `@binding(0)`. Each member occupies a 16-byte aligned slot (conservative alignment). Declare your WGSL struct to match this layout. Texture/RenderTexture uniforms are bound as separate entries starting at `@binding(1)` (texture) and `@binding(N+1)` (sampler), in declaration order.
import { WebGpuShaderFilter } from '@codexo/exojs' A high-level Filter subclass that renders the input texture through a user-provided WGSL fragment shader on the **WebGPU** backend.
For the WebGL2 backend use WebGl2ShaderFilter.
```ts const filter = new WebGpuShaderFilter({ fragmentSource: ` @group(0) @binding(0) var\<uniform> uResolution: vec2\<f32>; @group(0) @binding(1) var uTexture: texture_2d\<f32>; @group(0) @binding(2) var uSampler: sampler;
@fragment fn main(@location(0) vUv: vec2\<f32>) -> @location(0) vec4\<f32> { return textureSample(uTexture, uSampler, vUv); } `, uniforms: { uTime: 0.0 }, });
// Update uniforms each frame: filter.uniforms.uTime = performance.now() / 1000; sprite.filters = [filter]; ```
All non-texture user uniforms are packed into a single uniform buffer at `@binding(0)`. Each member occupies a 16-byte aligned slot (conservative alignment). Declare your WGSL struct to match this layout.
Texture/RenderTexture uniforms are bound as separate entries starting at `@binding(1)` (texture) and `@binding(N+1)` (sampler), in declaration order.
new(options: WebGpuShaderFilterOptions): WebGpuShaderFilter apply(backend: RenderBackend, input: RenderTexture, output: RenderTexture): void destroy(): void uniforms: Record<string, ShaderFilterUniformValue>