API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classWebGpuShaderFilter

@codexo/exojs / rendering / stable

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.

1
props
2
methods
0
events
Import
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.

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)
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.

Constructors 1
new(options: WebGpuShaderFilterOptions): WebGpuShaderFilter
Methods 2
apply(backend: RenderBackend, input: RenderTexture, output: RenderTexture): void
destroy(): void
Properties 1
uniforms: Record<string, ShaderFilterUniformValue>
Source