Shader
Index
Constructors
Properties
Accessors
Methods
- _setImages
- addImageSource
- compile
- dispose
- flagUniformsDirty
- getAttributeDefinitions
- getUniformDefinitions
- isCurrentlyBound
- removeImageSource
- setTexture
- setUniform
- setUniformAffineMatrix
- setUniformBoolean
- setUniformBuffer
- setUniformFloat
- setUniformFloatArray
- setUniformFloatColor
- setUniformFloatVector
- setUniformInt
- setUniformIntArray
- setUniformMatrix
- trySetUniform
- trySetUniformBoolean
- trySetUniformBuffer
- trySetUniformFloat
- trySetUniformFloatArray
- trySetUniformFloatColor
- trySetUniformFloatVector
- trySetUniformInt
- trySetUniformIntArray
- trySetUniformMatrix
- unuse
- use
Constructors
constructor
Parameters
options: ShaderOptions
specify shader vertex and fragment source
Returns Shader
Properties
publicattributes
Type declaration
[variableName string]: VertexAttributeDefinition
publicreadonlyfragmentSource
images
Set images to load into the shader as a sampler2d
publicreadonlyname
publicprogram
uniforms
Set uniforms key value pairs
publicreadonlyvertexSource
Accessors
publiccompiled
Returns whether the shader is compiled
Returns boolean
Methods
_setImages
Parameters
suppressWarning: boolean = false
Returns void
addImageSource
Parameters
samplerName: string
image: ImageSource
Returns void
compile
Compile the current shader against a webgl context
Returns WebGLProgram
dispose
Deletes the webgl program from the gpu
Returns void
publicflagUniformsDirty
Flags uniforms need to be re-uploaded on the next call to .use()
Returns void
getAttributeDefinitions
Returns VertexAttributeDefinition[]
getUniformDefinitions
Get's the uniform definitons
Returns UniformDefinition[]
isCurrentlyBound
Returns boolean
removeImageSource
Parameters
samplerName: string
Returns void
setTexture
Set a texture in a gpu texture slot
Parameters
slotNumber: number
texture: WebGLTexture
Returns void
setUniform
Set any available uniform type in webgl
For example setUniform('uniformMatrix2fv', 'u_my2x2_mat`, ...);
Type parameters
- TUniformType: UniformTypeNames
Parameters
uniformType: TUniformType
name: string
rest...value: RemoveFirstFromTuple<Parameters<WebGL2RenderingContext[TUniformType]>>
Returns void
setUniformAffineMatrix
Parameters
name: string
value: AffineMatrix
Returns void
setUniformBoolean
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
setUniformBuffer
Set a uniform buffer block with a Float32Array
Parameters
name: string
The of the binding block
data: Float32Array
Float32Array
optionalbindingPoint: number = 0
Returns void
setUniformFloat
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
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
setUniformFloatVector
setUniformInt
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
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
trySetUniform
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
- TUniformType: UniformTypeNames
Parameters
uniformType: TUniformType
name: string
rest...value: RemoveFirstFromTuple<Parameters<WebGL2RenderingContext[TUniformType]>>
Returns boolean
trySetUniformBoolean
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
trySetUniformBuffer
Parameters
name: string
data: Float32Array
bindingPoint: number = 0
Returns boolean
trySetUniformFloat
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
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
trySetUniformFloatVector
trySetUniformInt
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
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
unuse
Returns void
use
Binds the shader program
Returns void
Create a shader program in excalibur