import { IMat, IVec2, IVec3, IVec4 } from '@gglib/math'; import { Device } from '../Device'; import { ShaderProgram, Texture } from '../resources'; import { SamplerStateParams } from '../states'; /** * A union type combining all types that are supported by the {@link ShaderUniform} * * @public */ export declare type ShaderUniformValue = string | boolean | number | ArrayLike | Texture | IVec2 | IVec3 | IVec4 | IMat; /** * @public */ export interface ShaderUniformBinding { /** * The shader uniform (binding) name */ name: string; /** * The shader uniform type */ type: string; /** * The value to be set to bound uniform */ value: T; } /** * Constructor options for {@link ShaderUniform} * @public */ export interface ShaderUniformOptions { /** * The original name of the uniform as it appears in the shader source code * * @remarks * This is used to get the uniform location in the compiled program */ name: string; /** * The type of the uniform e.g. `float`, `vec2`, `vec3`, `mat4` */ type: string; /** * The binding name of the uniform by which the uniform will be accessible in the javascript world * * @remarks * Bindings are defined in the shader source code by adding a comment above a uniform e.g. * * ``` * // @binding lightDirection * uniform vec3 uLightDirection; * ``` */ binding?: string; /** * The default value of the uniform that will be set initially * * @remarks * Default values are defined in the shader source code by adding a comment above a uniform e.g. * * ```c * // @default [1, 1, 1] * uniform vec3 uLightDirection; * ``` */ default?: any; /** * The sampler state preset name e.g. 'LinearClamp', 'LinearWrap', 'PointClamp' or 'PointWrap' * * @remarks * Filters are defined in the shader source code by adding a comment above a uniform e.g. * * ```c * // @filter LinearWrap * uniform sampler2d uTexture * ``` */ filter?: string; /** * This is the sampler register index * * @remarks * Register index is defined in the shader source code by adding a comment above a uniform e.g. * * ```c * // @register 2 * uniform sampler2d uTexture; * ``` */ register?: number; } /** * @public */ export declare abstract class ShaderUniform { /** * The graphics device */ abstract readonly device: Device; /** * The rendering context */ /** * The shader program */ abstract readonly program: ShaderProgram; /** * Meta data and annotations of this uniform */ meta: any; /** * The binding name of this uniform */ name: string; /** * The type name of the uniform in the shader */ type: string; /** * The default value */ defaultValue: any; /** * The currently cached value */ cachedValue: any[]; dirty: boolean; set: (v: any, ...rest: any[]) => void; /** * The texture register index */ register: number; /** * The texture sampler parameters */ filter: SamplerStateParams; protected cacheX(x: number | boolean): boolean; protected cacheXY(x: number | boolean, y: number | boolean): boolean; protected cacheXYZ(x: number | boolean, y: number | boolean, z: number | boolean): boolean; protected cacheXYZW(x: number | boolean, y: number | boolean, z: number | boolean, w: number | boolean): boolean; /** * Sets an int value. Commits it to the uniform variable of the program if it has changed. */ abstract setInt(value: number): void; /** * Sets an int2 value. Commits it to the uniform variable of the program if it has changed. */ abstract setInt2(v1: number, v2: number): void; /** * Sets an int3 value. Commits it to the uniform variable of the program if it has changed. */ abstract setInt3(v1: number, v2: number, v3: number): void; /** * Sets an int4 value. Commits it to the uniform variable of the program if it has changed. */ abstract setInt4(v1: number, v2: number, v3: number, v4: number): void; /** * Sets a boolean value. Commits it to the uniform variable of the program if it has changed. */ abstract setBool(value: boolean): void; /** * Sets a boolean2 value. Commits it to the uniform variable of the program if it has changed. */ abstract setBool2(v1: boolean, v2: boolean): void; /** * Sets a boolean3 value. Commits it to the uniform variable of the program if it has changed. */ abstract setBool3(v1: boolean, v2: boolean, v3: boolean): void; /** * Sets a boolean4 value. Commits it to the uniform variable of the program if it has changed. */ abstract setBool4(v1: boolean, v2: boolean, v3: boolean, v4: boolean): void; /** * Sets a float value. Commits it to the uniform variable of the program if it has changed. */ abstract setFloat(value: number): void; /** * Sets a two component float value. Commits it to the uniform variable of the program if it has changed. */ abstract setFloat2(v1: number, v2: number): void; /** * Sets a three component float value. Commits it to the uniform variable of the program if it has changed. */ abstract setFloat3(v1: number, v2: number, v3: number): void; /** * Sets a four component float value. Commits it to the uniform variable of the program if it has changed. */ abstract setFloat4(v1: number, v2: number, v3: number, v4: number): void; /** * Sets a two component float value. Commits it to the uniform variable of the program if it has changed. */ abstract setVec2(value: { x: number; y: number; } | ArrayLike): void; /** * Sets a three component float value. Commits it to the uniform variable of the program if it has changed. */ abstract setVec3(value: { x: number; y: number; z: number; } | ArrayLike): void; /** * Sets a four component float value. Commits it to the uniform variable of the program if it has changed. */ abstract setVec4(value: { x: number; y: number; z: number; w: number; } | ArrayLike): void; /** * Sets a float array value. Commits it to the uniform. Skips (and clears) the cache. */ abstract setFloatArray(value: Float32List): void; /** * Sets a float array value. Commits it to the uniform. Skips (and clears) the cache. */ abstract setFloat2Array(value: Float32List): void; /** * Sets a float array value. Commits it to the uniform. Skips (and clears) the cache. */ abstract setFloat3Array(value: Float32List): void; /** * Sets a float array value. Commits it to the uniform. Skips (and clears) the cache. */ abstract setFloat4Array(value: Float32List): void; /** * Sets a integer array value. Commits it to the uniform. Skips (and clears) the cache. */ abstract setIntArray(value: Int32List): void; /** * Sets a integer array value. Commits it to the uniform. Skips (and clears) the cache. */ abstract setInt2Array(value: Int32List): void; /** * Sets a Int array value. Commits it to the uniform. Skips (and clears) the cache. */ abstract setInt3Array(value: Int32List): void; /** * Sets a Int array value. Commits it to the uniform. Skips (and clears) the cache. */ abstract setInt4Array(value: Int32List): void; /** * Sets a 2x2 matrix value on the uniform. Skips (and clears) the cache. */ abstract setMat2(value: { m: Float32List; }, transpose: boolean): void; /** * Sets a 3x3 matrix value on the uniform. Skips (and clears) the cache. */ abstract setMat3(value: { m: Float32List; }, transpose: boolean): void; /** * Sets a 4x4 matrix value on the uniform. Skips (and clears) the cache. */ abstract setMat4(value: { m: Float32List; }, transpose: boolean): void; /** * Binds a texture to this uniform */ setTexture(value: Texture): void; } //# sourceMappingURL=ShaderUniform.d.ts.map