UNPKG

@tolokoban/tgd

Version:

ToloGameDev library for WebGL2

51 lines 1.61 kB
import { TgdContext } from "../context"; import { TgdProgram } from "../program"; import { TgdCodeBloc, TgdCodeFunctions } from "../shader/code"; import { WebglUniformType } from "../types"; /** * Define the shader to be used in a filter. * * A filter is mostly a fragment shader working on a texture. * * Always available varyings: * * `vec2 varUV` * * Always available uniforms: * * `sampler2D texSource`: input texture. * * `float uniWidth`: width of the texture in pixels. * * `float uniHeight`: height of the texture in pixels. */ export declare class TgdFilter { /** * If you need more uniforms, define them here. * And set the values in the `setUniforms()` method. */ readonly uniforms: { [name: string]: WebglUniformType; }; /** * The code of a `vec4 applyColor()` function. * Must return a `vec4` color. */ readonly fragmentShaderCode: TgdCodeBloc; readonly extraFunctions: TgdCodeFunctions | TgdCodeBloc; readonly setUniforms: (_parameters: TgdFilterSerUniformsParameters) => void; constructor(options?: Partial<TgdFilterOptions>); /** Cleanup function. */ delete(): void; } export interface TgdFilterOptions { uniforms: { [name: string]: WebglUniformType; }; fragmentShaderCode: TgdCodeBloc; extraFunctions: TgdCodeFunctions | TgdCodeBloc; setUniforms(parameters: TgdFilterSerUniformsParameters): void; } export interface TgdFilterSerUniformsParameters { context: TgdContext; program: TgdProgram; time: number; delay: number; } //# sourceMappingURL=filter.d.ts.map