import { TypeToken } from '@gglib/utils'; import { ShaderTechnique, ShaderTechniqueOptions } from './ShaderTechnique'; import { Device } from './Device'; import { ShaderProgram, ShaderProgramOptions, ShaderUniformValue } from './resources'; import { ShaderPass } from './ShaderPass'; /** * Constructor options for {@link ShaderEffect} * * @public */ export interface ShaderEffectOptions { /** * A user defined name of the effect */ name?: string; /** * The default set of parameters */ parameters?: ShaderEffectParameters; /** * A collection of programs of this effect * * @remarks * `techniques` option is mutually exclusive with `program` option */ techniques?: ReadonlyArray | ShaderTechnique; /** * The name or index of the default technique of an effect. Defaults to `0` */ technique?: string | number; /** * The program to be used on this effect * * @remarks * `program` option is mutually exclusive with `techniques` option. * If this is given, then `techniques` and `technique` options are ignored and * instead created from this single program */ program?: ShaderProgram | ShaderProgramOptions; } /** * @public */ export interface ShaderEffectParameters { [key: string]: ShaderUniformValue; } /** * Defines a collection of {@link ShaderTechnique}s. * * @public * @remarks * Holds one active {@link ShaderTechnique} * A shader effect can hold several shader programs * There is only one active technique at a time which can be switched via `useTechnique`. */ export declare class ShaderEffect

{ /** * A symbol identifying the Array {@link ShaderEffect} type. */ static readonly Array: TypeToken[]>; /** * A symbol identifying the {@link ShaderEffectOptions} type. */ static readonly Options: TypeToken; /** * A symbol identifying the Array {@link ShaderEffectOptions} type. */ static readonly OptionsArray: TypeToken; /** * The graphics device */ readonly device: Device; /** * A user defined name of the effect */ readonly name: string; /** * The effect parameters that have been specified for this effect * * @remarks * When using {@link ShaderEffect.draw} these parameters are used as defaults but can be overridden */ readonly parameters: P; /** * The technique collection */ readonly techniques: ReadonlyArray; /** * The technique that is currently active */ readonly technique: ShaderTechnique; private readonly techniquesByName; constructor(device: Device, options?: ShaderEffectOptions); /** * Allows to re-initialize the shader effect * * @param options - The options for initialization */ setup(options: ShaderEffectOptions): void; /** * Switches to another technique identified by given name or index */ useTechnique(nameOrIndex: number | string): this; /** * Gets a technique by name or index * * @remarks * Throws an error if no technique can be found */ getTechnique(nameOrIndex: string | number): ShaderTechnique; /** * Gets a pass by name or index from the currently active {@link ShaderEffect.technique} */ pass(passIdentifier: string | number): ShaderPass; /** * Calls `draw` on given object for each {@link ShaderPass} of the current {@link ShaderEffect.technique} */ draw(drawable: { draw: (p: ShaderProgram) => void; }, parameters?: P): void; drawQuad(flipY?: boolean, parameters?: P): void; /** * Creates a clone of this effect */ clone(): ShaderEffect; /** * Gets a shader parameter by name * * @remarks * This simply gets the parameter from {@link ShaderEffect.parameters} by its name. * The method exists to allow type assertion on the returned value in typescript e.g. * * ```ts * getParameter('World').setTranslation(...) * ``` * * @param name - The name of the parameter */ getParameter(name: string): T | null; } //# sourceMappingURL=ShaderEffect.d.ts.map