Skip to content

1681-engine / postfx / FxShaderSpec

Interface: FxShaderSpec ​

Defined in: src/postfx/fxShader.ts:24

One effect's shader: its uniforms, and the body of its fragment function in GLSL (WebGL 2) and WGSL (WebGPU).

Both bodies are given the same helpers, so they read alike:

  • frameUv (vec2): 0–1 across the filtered area, whatever the size of the texture Pixi hands over;
  • framePx (vec2): the filtered area's size in pixels; texel (vec2): one input pixel in texture coordinates;
  • sampleAt(coord): the input at a texture coordinate, clamped inside the area; toCoord(uv): frame uv back to one;
  • coord: this fragment's texture coordinate; src: the input there (premultiplied alpha);
  • uMap / sampleMap(coord) when the effect has a second texture (map: true). GLSL reads its uniforms by name; WGSL through fx.<name>. Each body ends by writing result.

Properties ​

glsl ​

ts
glsl: string;

Defined in: src/postfx/fxShader.ts:27


map? ​

ts
optional map?: boolean;

Defined in: src/postfx/fxShader.ts:30

A second texture the effect samples (bloom's blurred light).


name ​

ts
name: string;

Defined in: src/postfx/fxShader.ts:25


uniforms ​

ts
uniforms: FxUniforms;

Defined in: src/postfx/fxShader.ts:26


wgsl ​

ts
wgsl: string;

Defined in: src/postfx/fxShader.ts:28

Released under the MIT License.