import { GLSLSource, Inputs } from "../glsl"; import { Output } from "../output"; import type { Synth } from "../synth"; import { Texture } from "../texture"; import { Generator } from "./generator"; import { TransformFeedback, TransformFeedbackProps } from "./transformFeedback"; import { VAO, VAOProps } from "./vao"; export declare const GL_FRAGMENT_SHADER = 35632; export declare const GL_VERTEX_SHADER = 35633; export type Precision = "highp" | "mediump" | "lowp"; export type UniformValue = number | [number, number] | [number, number, number] | [number, number, number, number] | number[] | Float32Array | WebGLTexture | Texture | null; export type UniformType = "bool" | "float" | `float[${number}]` | `int[${number}]` | `uint[${number}]` | "int" | "uint" | "vec2" | "vec3" | "vec4" | "sampler2D" | "samplerCube" | "sampler2DArray" | "mat3" | "mat4"; export type Uniforms = { name: string; type: UniformType; value: ((synth: Synth) => UniformValue) | UniformValue; }[]; export type ShaderUniforms = Record; export type ShaderDefines = Record; export declare enum ShaderVaryingsMode { IN = 1, OUT = 2, SHARED = 3 } export type ShaderVaryings = Record; export type CullFaceMode = "back" | "front" | "both" | "none" | false; export interface ShaderProps { name?: string; precision?: Precision; width?: number; height?: number; fragment?: string | GLSLSource | Generator | boolean; vertex?: string | GLSLSource | Generator; uniforms?: Uniforms | ShaderUniforms; defines?: ShaderDefines; varyings?: ShaderVaryings; vao?: VAO | VAOProps; cullFace?: CullFaceMode; depthTest?: boolean; transformFeedback?: TransformFeedback | TransformFeedbackProps; autoClear?: boolean; blendMode?: [number, number] | null; } export declare class ShaderError extends Error { constructor(message: string); } export declare class Shader { #private; synth: Synth; name: string; precision: Precision; width: number; height: number; gl: WebGL2RenderingContext; program: WebGLProgram; fragmentShader: WebGLShader; vertexShader: WebGLShader; fragmentSource: string | Generator | false; vertexSource: string | Generator; fragmentGenerated: string; vertexGenerated: string; drawCalls: number; needsUpdate: boolean; uniformsLocation: Record; _autoClear: boolean; blendMode: [number, number] | null; texture?: Texture; _uniforms: Uniforms; shaderUniforms: ShaderUniforms; defines: ShaderDefines; _varyings: ShaderVaryings; _cullFace: number; _depthTest: boolean; VAO?: VAO; _transformFeedback?: TransformFeedback; _mrtFBO: WebGLFramebuffer | null; constructor(synth: Synth, props?: ShaderProps, skip?: boolean); compile(): this; blend(mode: [number, number] | null): this; cullFace(mode?: CullFaceMode): this; vao(vao: VAO | VAOProps): this; transformFeedback(tf: TransformFeedback | TransformFeedbackProps): this; frag(fragment: string | GLSLSource | Generator | boolean): this; fragment(fragment: string | GLSLSource | Generator | boolean): this; vert(vertex: string | GLSLSource | Generator): this; vertex(vertex: string | GLSLSource | Generator): this; define(toAdd: Record | string, value?: string | number | boolean): this; varyngs(v: ShaderVaryings): this; uniforms(uniforms: Record UniformValue)> | Inputs | Uniforms | ShaderUniforms): this; uniform(toAdd: Record UniformValue)> | Inputs | Uniforms | ShaderUniforms, value?: UniformValue): this; resize(width: number, height: number): this; updateShaderUniforms(uniforms?: Uniforms): this; update(uniforms?: Uniforms): this; forceUpdate(): this; autoClear(autoClear?: boolean): this; draw(to?: Texture | Texture[]): this; out(texture?: Texture | Output): this; clear(): void; activate(active?: boolean, force?: boolean): this; bindUniforms(initialTextureUnit?: number): number; static defaultGydraShader: ShaderProps; static defaultGydraVAO: VAO; }