Skip to main content

ShaderPipeline

Apply multiple shaders in succession

Index

Constructors

constructor

Properties

cache

cache: boolean = false

framebuffers

framebuffers: [Framebuffer, Framebuffer]

graphicsContext

height

height: number

pipeline

pipeline: QuadRenderer[] = []

width

width: number

Methods

bind

  • bind(): void
  • Returns void

draw

  • draw(inputTexture?: WebGLTexture): WebGLTexture
  • If a texture is provided run the pipeline on that texture, otherwise run on the currently bound frame buffer

    Returns a final texture that is the result of the pipeline


    Parameters

    • optionalinputTexture: WebGLTexture

    Returns WebGLTexture

flagDirty

  • flagDirty(): void
  • Returns void

redirectDraw

  • redirectDraw(draw: () => any): WebGLTexture
  • Redirects a provided draw function


    Parameters

    • draw: () => any

      Returns WebGLTexture

    resize

    • resize(width: number, height: number): void
    • Parameters

      • width: number
      • height: number

      Returns void

    setTexture

    • setTexture(slotNumber: number, texture: WebGLTexture): void
    • Set a texture in a gpu texture slot


      Parameters

      • slotNumber: number
      • texture: WebGLTexture

      Returns void

    setUniform

    • setUniform<TUniformType>(uniformType: TUniformType, name: string, ...value: RemoveFirstFromTuple<Parameters<WebGLRenderingContext[TUniformType]>>): void
    • Set any available uniform type in webgl

      For example setUniform('uniformMatrix2fv', 'u_my2x2_mat`, ...);


      Type parameters

      Parameters

      • uniformType: TUniformType
      • name: string
      • rest...value: RemoveFirstFromTuple<Parameters<WebGLRenderingContext[TUniformType]>>

      Returns void

    setUniformAffineMatrix

    • setUniformAffineMatrix(name: string, value: AffineMatrix): void

    setUniformBoolean

    • setUniformBoolean(name: string, value: boolean): void
    • Set a boolean uniform for the current shader

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      • name: string
      • value: boolean

      Returns void

    setUniformFloat

    • setUniformFloat(name: string, value: number): void
    • Set a float uniform for the current shader

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      • name: string
      • value: number

      Returns void

    setUniformFloatArray

    • setUniformFloatArray(name: string, value: number[]): void
    • Set a float array uniform for the current shader

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      • name: string
      • value: number[]

      Returns void

    setUniformFloatColor

    • setUniformFloatColor(name: string, value: Color): void
    • Set a Color uniform for the current shader

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      Returns void

    setUniformFloatVector

    • setUniformFloatVector(name: string, value: Vector): void
    • Set a Vector uniform for the current shader

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      Returns void

    setUniformInt

    • setUniformInt(name: string, value: number): void
    • Set an integer uniform for the current shader

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      • name: string
      • value: number

      Returns void

    setUniformIntArray

    • setUniformIntArray(name: string, value: number[]): void
    • Set an integer array uniform for the current shader

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      • name: string
      • value: number[]

      Returns void

    setUniformMatrix

    • setUniformMatrix(name: string, value: Matrix): void
    • Set an Matrix uniform for the current shader

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      Returns void

    trySetUniform

    • trySetUniform<TUniformType>(uniformType: TUniformType, name: string, ...value: UniformParameters<TUniformType>): boolean
    • Set any available uniform type in webgl. Will try to set the uniform, will return false if the uniform didn't exist, true if it was set.

      WILL NOT THROW on error

      For example setUniform('uniformMatrix2fv', 'u_my2x2_mat`, ...);


      Type parameters

      Parameters

      Returns boolean

    trySetUniformBoolean

    • trySetUniformBoolean(name: string, value: boolean): boolean
    • Set a boolean uniform for the current shader, WILL NOT THROW on error.

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      • name: string
      • value: boolean

      Returns boolean

    trySetUniformFloat

    • trySetUniformFloat(name: string, value: number): boolean
    • Set a float uniform for the current shader, WILL NOT THROW on error.

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      • name: string
      • value: number

      Returns boolean

    trySetUniformFloatArray

    • trySetUniformFloatArray(name: string, value: number[]): boolean
    • Set a float array uniform for the current shader, WILL NOT THROW on error.

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      • name: string
      • value: number[]

      Returns boolean

    trySetUniformFloatColor

    • trySetUniformFloatColor(name: string, value: Color): boolean
    • Set a Color uniform for the current shader, WILL NOT THROW on error.

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      Returns boolean

    trySetUniformFloatVector

    • trySetUniformFloatVector(name: string, value: Vector): boolean
    • Set a Vector uniform for the current shader, WILL NOT THROW on error.

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      Returns boolean

    trySetUniformInt

    • trySetUniformInt(name: string, value: number): boolean
    • Set an integer uniform for the current shader, WILL NOT THROW on error.

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      • name: string
      • value: number

      Returns boolean

    trySetUniformIntArray

    • trySetUniformIntArray(name: string, value: number[]): boolean
    • Set an integer array uniform for the current shader, WILL NOT THROW on error.

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      • name: string
      • value: number[]

      Returns boolean

    trySetUniformMatrix

    • trySetUniformMatrix(name: string, value: Matrix): boolean
    • Set an Matrix uniform for the current shader, WILL NOT THROW on error.

      Important Must call ex.Shader.use() before setting a uniform!


      Parameters

      Returns boolean

    unbind

    • unbind(): void
    • Returns void