Class Effect
Hierarchy
- Effect
Implements
Index
Constructors
Properties
- defines
- name
- on
Bind - on
Compile Observable - on
Compiled - on
Error - on
Error Observable - set
Array - set
Array2 - set
Array3 - set
Array4 - set
Color3 - set
Color4 - set
Direct Color4 - set
Float - set
Float2 - set
Float3 - set
Float4 - set
Int - set
Int2 - set
Int3 - set
Int4 - set
Int Array - set
Int Array2 - set
Int Array3 - set
Int Array4 - set
Matrices - set
Matrix - set
Matrix2x2 - set
Matrix3x3 - set
Quaternion - set
Vector2 - set
Vector3 - set
Vector4 - unique
Id - Includes
Shaders Store - Log
Shader Code On Compilation Error - Shaders
Store
Accessors
Methods
- all
Fallbacks Processed - bind
Uniform Block - bind
Uniform Buffer - dispose
- execute
When Compiled - get
Attribute Location - get
Attribute Location By Name - get
Attributes Count - get
Attributes Names - get
Compilation Error - get
Engine - get
Index Parameters - get
Pipeline Context - get
Samplers - get
Uniform - get
Uniform Buffers Names - get
Uniform Index - get
Uniform Names - is
Ready - set
Bool - set
Depth Stencil Texture - set
External Texture - set
Float Array - set
Float Array2 - set
Float Array3 - set
Float Array4 - set
Storage Buffer - set
Texture - set
Texture Array - set
Texture From Post Process - set
Texture From Post Process Output - set
Texture Sampler - Register
Shader - Reset
Cache
Constructors
constructor
Instantiates an effect. An effect can be used to create/manage/execute vertex and fragment shaders.
Parameters
baseName: any
Name of the effect.
attributesNamesOrOptions: string[] | IEffectCreationOptions
List of attribute names that will be passed to the shader or set of all options to create the effect.
uniformsNamesOrEngine: string[] | ThinEngine
List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
Optional samplers: Nullable<string[]>
List of sampler variables that will be passed to the shader.
Optional engine: ThinEngine
Engine to be used to render the effect
Optional defines: Nullable<string>
Define statements to be added to the shader.
Optional fallbacks: Nullable<IEffectFallbacks>
Possible fallbacks for this effect to improve performance when needed.
Optional onCompiled: Nullable<((effect: Effect) => void)>
Callback that will be called when the shader is compiled.
Optional onError: Nullable<((effect: Effect, errors: string) => void)>
Callback that will be called if an error occurs during shader compilation.
Optional indexParameters: any
Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
Optional key: string
Effect Key identifying uniquely compiled shader variants
Optional shaderLanguage: ShaderLanguage
the language the shader is written in (default: GLSL)
Returns Effect
Properties
definesSearch playground for defines
String container all the define statements that should be set on the shader.
nameSearch playground for name
Name of the effect.
on BindSearch playground for onBind
Callback that will be called when effect is bound.
on Compile ObservableSearch playground for onCompileObservable
Observable that will be called when the shader is compiled. It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
on CompiledSearch playground for onCompiled
Callback that will be called when the shader is compiled.
on ErrorSearch playground for onError
Callback that will be called if an error occurs during shader compilation.
on Error ObservableSearch playground for onErrorObservable
Observable that will be called if an error occurs during shader compilation.
set ArraySearch playground for setArray
Type declaration
Sets an array on a uniform variable.
Parameters
uniformName: string
Name of the variable.
array: number[]
array to be set.
Returns Effect
this effect.
set Array2Search playground for setArray2
Type declaration
Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
Parameters
uniformName: string
Name of the variable.
array: number[]
array to be set.
Returns Effect
this effect.
set Array3Search playground for setArray3
Type declaration
Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
Parameters
uniformName: string
Name of the variable.
array: number[]
array to be set.
Returns Effect
this effect.
set Array4Search playground for setArray4
Type declaration
Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
Parameters
uniformName: string
Name of the variable.
array: number[]
array to be set.
Returns Effect
this effect.
set Color3Search playground for setColor3
Type declaration
Sets a Color3 on a uniform variable.
Parameters
uniformName: string
Name of the variable.
color3: IColor3Like
Value to be set.
Returns Effect
this effect.
set Color4Search playground for setColor4
Type declaration
Sets a Color4 on a uniform variable.
Parameters
uniformName: string
Name of the variable.
color3: IColor3Like
Value to be set.
alpha: number
Alpha value to be set.
Returns Effect
this effect.
set Direct Color4Search playground for setDirectColor4
Type declaration
Sets a Color4 on a uniform variable
Parameters
uniformName: string
defines the name of the variable
color4: IColor4Like
defines the value to be set
Returns Effect
this effect.
set FloatSearch playground for setFloat
Type declaration
Sets a float on a uniform variable.
Parameters
uniformName: string
Name of the variable.
value: number
value to be set.
Returns Effect
this effect.
set Float2Search playground for setFloat2
Type declaration
Sets a float2 on a uniform variable.
Parameters
uniformName: string
Name of the variable.
x: number
First float in float2.
y: number
Second float in float2.
Returns Effect
this effect.
set Float3Search playground for setFloat3
Type declaration
Sets a float3 on a uniform variable.
Parameters
uniformName: string
Name of the variable.
x: number
First float in float3.
y: number
Second float in float3.
z: number
Third float in float3.
Returns Effect
this effect.
set Float4Search playground for setFloat4
Type declaration
Sets a float4 on a uniform variable.
Parameters
uniformName: string
Name of the variable.
x: number
First float in float4.
y: number
Second float in float4.
z: number
Third float in float4.
w: number
Fourth float in float4.
Returns Effect
this effect.
set IntSearch playground for setInt
Type declaration
Sets an integer value on a uniform variable.
Parameters
uniformName: string
Name of the variable.
value: number
Value to be set.
Returns Effect
this effect.
set Int2Search playground for setInt2
Type declaration
Sets an int2 value on a uniform variable.
Parameters
uniformName: string
Name of the variable.
x: number
First int in int2.
y: number
Second int in int2.
Returns Effect
this effect.
set Int3Search playground for setInt3
Type declaration
Sets an int3 value on a uniform variable.
Parameters
uniformName: string
Name of the variable.
x: number
First int in int3.
y: number
Second int in int3.
z: number
Third int in int3.
Returns Effect
this effect.
set Int4Search playground for setInt4
Type declaration
Sets an int4 value on a uniform variable.
Parameters
uniformName: string
Name of the variable.
x: number
First int in int4.
y: number
Second int in int4.
z: number
Third int in int4.
w: number
Fourth int in int4.
Returns Effect
this effect.
set Int ArraySearch playground for setIntArray
Type declaration
Sets an int array on a uniform variable.
Parameters
uniformName: string
Name of the variable.
array: Int32Array
array to be set.
Returns Effect
this effect.
set Int Array2Search playground for setIntArray2
Type declaration
Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
Parameters
uniformName: string
Name of the variable.
array: Int32Array
array to be set.
Returns Effect
this effect.
set Int Array3Search playground for setIntArray3
Type declaration
Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
Parameters
uniformName: string
Name of the variable.
array: Int32Array
array to be set.
Returns Effect
this effect.
set Int Array4Search playground for setIntArray4
Type declaration
Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
Parameters
uniformName: string
Name of the variable.
array: Int32Array
array to be set.
Returns Effect
this effect.
set MatricesSearch playground for setMatrices
Type declaration
Sets matrices on a uniform variable.
Parameters
uniformName: string
Name of the variable.
matrices: number[] | Float32Array
matrices to be set.
Returns Effect
this effect.
set MatrixSearch playground for setMatrix
Type declaration
Sets matrix on a uniform variable.
Parameters
uniformName: string
Name of the variable.
matrix: IMatrixLike
matrix to be set.
Returns Effect
this effect.
set Matrix2x2Search playground for setMatrix2x2
Type declaration
Sets a 2x2 matrix on a uniform variable. (Specified as [1,2,3,4] will result in [1,2][3,4] matrix)
Parameters
uniformName: string
Name of the variable.
matrix: number[] | Float32Array
matrix to be set.
Returns Effect
this effect.
set Matrix3x3Search playground for setMatrix3x3
Type declaration
Sets a 3x3 matrix on a uniform variable. (Specified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
Parameters
uniformName: string
Name of the variable.
matrix: number[] | Float32Array
matrix to be set.
Returns Effect
this effect.
set QuaternionSearch playground for setQuaternion
Type declaration
Sets a Quaternion on a uniform variable.
Parameters
uniformName: string
Name of the variable.
quaternion: IQuaternionLike
Value to be set.
Returns Effect
this effect.
set Vector2Search playground for setVector2
Type declaration
Sets a Vector2 on a uniform variable.
Parameters
uniformName: string
Name of the variable.
vector2: IVector2Like
vector2 to be set.
Returns Effect
this effect.
set Vector3Search playground for setVector3
Type declaration
Sets a Vector3 on a uniform variable.
Parameters
uniformName: string
Name of the variable.
vector3: IVector3Like
Value to be set.
Returns Effect
this effect.
set Vector4Search playground for setVector4
Type declaration
Sets a Vector4 on a uniform variable.
Parameters
uniformName: string
Name of the variable.
vector4: IVector4Like
Value to be set.
Returns Effect
this effect.
unique IdSearch playground for uniqueId
Unique ID of the effect.
Static Includes Shaders StoreSearch playground for IncludesShadersStore
Store of each included file for a shader (The can be looked up using effect.key)
Type declaration
[key: string]: string
Static Log Shader Code On Compilation ErrorSearch playground for LogShaderCodeOnCompilationError
Enable logging of the shader code when a compilation error occurs
Static Shaders StoreSearch playground for ShadersStore
Store of each shader (The can be looked up using effect.key)
Type declaration
[key: string]: string
Accessors
fragment Source Code
Gets the fragment shader source code of this effect
Returns string
is Supported
Checks if the effect is supported. (Must be called after compilation)
Returns boolean
key
Unique key for this effect
Returns string
on Bind Observable
Observable that will be called when effect is bound.
Returns Observable<Effect>
raw Fragment Source Code
Gets the fragment shader source code before it has been processed by the preprocessor
Returns string
raw Vertex Source Code
Gets the vertex shader source code before it has been processed by the preprocessor
Returns string
vertex Source Code
Gets the vertex shader source code of this effect
Returns string
Static Shaders Repository
Gets or sets the relative url used to load shaders if using the engine in non-minified mode
Returns string
Gets or sets the relative url used to load shaders if using the engine in non-minified mode
Parameters
repo: string
Returns void
Methods
all Fallbacks ProcessedSearch playground for allFallbacksProcessed
Gets a boolean indicating that all fallbacks were used during compilation
Returns boolean
true if all fallbacks were used
bind Uniform BlockSearch playground for bindUniformBlock
Binds block to a uniform.
Parameters
blockName: string
Name of the block to bind.
index: number
Index to bind.
Returns void
bind Uniform BufferSearch playground for bindUniformBuffer
Binds a buffer to a uniform.
Parameters
buffer: DataBuffer
Buffer to bind.
name: string
Name of the uniform variable to bind to.
Returns void
disposeSearch playground for dispose
Release all associated resources.
Returns void
execute When CompiledSearch playground for executeWhenCompiled
get Attribute LocationSearch playground for getAttributeLocation
Returns the attribute at the given index.
Parameters
index: number
The index of the attribute.
Returns number
The location of the attribute.
get Attribute Location By NameSearch playground for getAttributeLocationByName
Returns the attribute based on the name of the variable.
Parameters
name: string
of the attribute to look up.
Returns number
the attribute location.
get Attributes CountSearch playground for getAttributesCount
The number of attributes.
Returns number
the number of attributes.
get Attributes NamesSearch playground for getAttributesNames
The set of names of attribute variables for the shader.
Returns string[]
An array of attribute names.
get Compilation ErrorSearch playground for getCompilationError
The error from the last compilation.
Returns string
the error string.
get EngineSearch playground for getEngine
The engine the effect was initialized with.
Returns Engine
the engine.
get Index ParametersSearch playground for getIndexParameters
Returns the index parameters used to create the effect
Returns any
The index parameters object
get Pipeline ContextSearch playground for getPipelineContext
The pipeline context for this effect
Returns Nullable<IPipelineContext>
the associated pipeline context
get SamplersSearch playground for getSamplers
Returns an array of sampler variable names
Returns string[]
The array of sampler variable names.
get UniformSearch playground for getUniform
Returns the attribute based on the name of the variable.
Parameters
uniformName: string
of the uniform to look up.
Returns Nullable<WebGLUniformLocation>
the location of the uniform.
get Uniform Buffers NamesSearch playground for getUniformBuffersNames
Returns an array of uniform buffer variable names
Returns string[]
The array of uniform buffer variable names.
get Uniform IndexSearch playground for getUniformIndex
Gets the index of a uniform variable.
Parameters
uniformName: string
of the uniform to look up.
Returns number
the index.
get Uniform NamesSearch playground for getUniformNames
Returns an array of uniform variable names
Returns string[]
The array of uniform variable names.
is ReadySearch playground for isReady
If the effect has been compiled and prepared.
Returns boolean
if the effect is compiled and prepared.
set BoolSearch playground for setBool
Sets a boolean on a uniform variable.
Parameters
uniformName: string
Name of the variable.
bool: boolean
value to be set.
Returns Effect
this effect.
set Depth Stencil TextureSearch playground for setDepthStencilTexture
Sets a depth stencil texture from a render target on the engine to be used in the shader.
Parameters
channel: string
Name of the sampler variable.
texture: Nullable<RenderTargetTexture>
Texture to set.
Returns void
set External TextureSearch playground for setExternalTexture
Sets an external texture on the engine to be used in the shader.
Parameters
name: string
Name of the external texture variable.
texture: Nullable<ExternalTexture>
Texture to set.
Returns void
set Float ArraySearch playground for setFloatArray
Sets an float array on a uniform variable.
Parameters
uniformName: string
Name of the variable.
array: FloatArray
array to be set.
Returns Effect
this effect.
set Float Array2Search playground for setFloatArray2
Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
Parameters
uniformName: string
Name of the variable.
array: FloatArray
array to be set.
Returns Effect
this effect.
set Float Array3Search playground for setFloatArray3
Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
Parameters
uniformName: string
Name of the variable.
array: FloatArray
array to be set.
Returns Effect
this effect.
set Float Array4Search playground for setFloatArray4
Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
Parameters
uniformName: string
Name of the variable.
array: FloatArray
array to be set.
Returns Effect
this effect.
set Storage BufferSearch playground for setStorageBuffer
Sets a storage buffer on the engine to be used in the shader.
Parameters
name: string
Name of the storage buffer variable.
buffer: Nullable<StorageBuffer>
Storage buffer to set.
Returns void
set TextureSearch playground for setTexture
Sets a texture on the engine to be used in the shader.
Parameters
channel: string
Name of the sampler variable.
texture: Nullable<ThinTexture>
Texture to set.
Returns void
set Texture ArraySearch playground for setTextureArray
Sets an array of textures on the engine to be used in the shader.
Parameters
channel: string
Name of the variable.
textures: ThinTexture[]
Textures to set.
Returns void
set Texture From Post ProcessSearch playground for setTextureFromPostProcess
Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
Parameters
channel: string
Name of the sampler variable.
postProcess: Nullable<PostProcess>
Post process to get the input texture from.
Returns void
set Texture From Post Process OutputSearch playground for setTextureFromPostProcessOutput
(Warning! setTextureFromPostProcessOutput may be desired instead) Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
Parameters
channel: string
Name of the sampler variable.
postProcess: Nullable<PostProcess>
Post process to get the output texture from.
Returns void
set Texture SamplerSearch playground for setTextureSampler
Sets a sampler on the engine to be used in the shader.
Parameters
name: string
Name of the sampler variable.
sampler: Nullable<TextureSampler>
Sampler to set.
Returns void
Static Register ShaderSearch playground for RegisterShader
This function will add a new shader to the shader store
Parameters
name: string
the name of the shader
Optional pixelShader: string
optional pixel shader content
Optional vertexShader: string
optional vertex shader content
Optional shaderLanguage: ShaderLanguage
the language the shader is written in (default: GLSL)
Returns void
Static Reset CacheSearch playground for ResetCache
Resets the cache of effects.
Returns void
Effect containing vertex and fragment shader that can be executed on an object.