UNPKG

@tolokoban/tgd

Version:

ToloGameDev library for WebGL2

56 lines 1.85 kB
import { TgdProgram } from "../program"; import { TgdCodeBloc, TgdCodeFunctions } from "../shader/code"; import { TgdTextureCube, TgdTexture2D } from "../texture"; 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 uniTexture`: input texture. * * `float uniWidth`: width of the texture in pixels. * * `float uniHeight`: height of the texture in pixels. */ export declare class TgdFilter { protected static id: number; name: string; /** * If you need more uniforms, define them here. * And set the values in the `setUniforms()` method. */ readonly uniforms: Record<string, WebglUniformType>; readonly textures: Record<string, TgdTexture2D | TgdTextureCube>; /** * 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 { name: string; uniforms: { [name: string]: WebglUniformType; }; textures?: Record<string, TgdTexture2D | TgdTextureCube>; fragmentShaderCode: TgdCodeBloc; extraFunctions: TgdCodeFunctions | TgdCodeBloc; setUniforms(parameters: TgdFilterSerUniformsParameters): void; } export interface TgdFilterSerUniformsParameters { context: { gl: WebGL2RenderingContext; }; program: TgdProgram; time: number; delta: number; } //# sourceMappingURL=filter.d.ts.map