/** * A simplified shader class for applying custom fragment effects to renderables. * Only requires a fragment `apply()` function — the vertex shader, uniforms, and * texture sampling boilerplate are handled automatically. * In Canvas mode, the shader is silently disabled (all methods become no-ops). * @category Rendering * @example * // create a grayscale effect * mySprite.shader = new ShaderEffect(renderer, ` * vec4 apply(vec4 color, vec2 uv) { * float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114)); * return vec4(vec3(gray), color.a); * } * `); * @example * // create an effect with a custom uniform * const pulse = new ShaderEffect(renderer, ` * uniform float uTime; * vec4 apply(vec4 color, vec2 uv) { * float brightness = 0.8 + 0.2 * sin(uTime * 3.0); * return vec4(color.rgb * brightness, color.a); * } * `); * mySprite.shader = pulse; * // update the uniform each frame * pulse.setUniform("uTime", time); */ export default class ShaderEffect { /** * @param {WebGLRenderer|CanvasRenderer} renderer - the current renderer instance * @param {string} fragmentBody - GLSL code containing a `vec4 apply(vec4 color, vec2 uv)` function * that receives the sampled pixel color and UV coordinates, and returns the modified color. * You can declare additional `uniform` variables before the `apply()` function. * @param {string} [precision=auto detected] - float precision ('lowp', 'mediump' or 'highp') */ constructor(renderer: WebGLRenderer | CanvasRenderer, fragmentBody: string, precision?: string); /** * whether this effect is active (false in Canvas mode) * @type {boolean} */ enabled: boolean; /** @ignore */ _shader: GLShader | undefined; /** * Set the uniform to the given value * @param {string} name - the uniform name * @param {object|Float32Array} value - the value to assign to that uniform */ setUniform(name: string, value: object | Float32Array): void; /** @ignore */ bind(): void; /** @ignore */ getAttribLocation(name: any): number; /** @ignore */ setVertexAttributes(gl: any, attributes: any, stride: any): void; /** @ignore */ get program(): WebGLProgram | null; /** @ignore */ get vertex(): string | null; /** @ignore */ get fragment(): string | null; /** @ignore */ get attributes(): {}; /** @ignore */ get uniforms(): object; /** * destroy this shader effect */ destroy(): void; } import GLShader from "./glshader.js"; //# sourceMappingURL=shadereffect.d.ts.map