Class UniformBuffer
Hierarchy
- UniformBuffer
Index
Constructors
Properties
- update
Array - update
Color3 - update
Color4 - update
Direct Color4 - update
Float - update
Float2 - update
Float3 - update
Float4 - update
Float Array - update
Int - update
Int2 - update
Int3 - update
Int4 - update
Int Array - update
Matrices - update
Matrix - update
Matrix2x2 - update
Matrix3x3 - updateUInt
- updateUInt2
- updateUInt3
- updateUInt4
- updateUInt
Array - update
Vector3 - update
Vector4
Accessors
Methods
Constructors
constructor
Instantiates a new Uniform buffer objects.
Handles blocks of uniform on the GPU.
If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
For more information, please refer to :
Parameters
engine: ThinEngine
Define the engine the buffer is associated with
Optional data: number[]
Define the data contained in the buffer
Optional dynamic: boolean
Define if the buffer is updatable
Optional name: string
to assign to the buffer (debugging purpose)
Optional forceNoUniformBuffer: boolean
define that this object must not rely on UBO objects
Returns UniformBuffer
Properties
update ArraySearch playground for updateArray
Type declaration
Lambda to Update an array of number in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
array: number[]
Returns void
update Color3Search playground for updateColor3
Type declaration
Lambda to Update vec3 of float from a Color in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
color: IColor3Like
Optional suffix: string
Returns void
update Color4Search playground for updateColor4
Type declaration
Lambda to Update vec4 of float from a Color in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
color: IColor3Like
alpha: number
Optional suffix: string
Returns void
update Direct Color4Search playground for updateDirectColor4
Type declaration
Lambda to Update vec4 of float from a Color in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
color: IColor4Like
Optional suffix: string
Returns void
update FloatSearch playground for updateFloat
Type declaration
Lambda to Update a single float in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
x: number
Returns void
update Float2Search playground for updateFloat2
Type declaration
Lambda to Update a vec2 of float in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
x: number
y: number
Optional suffix: string
Returns void
update Float3Search playground for updateFloat3
Type declaration
Lambda to Update a vec3 of float in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
x: number
y: number
z: number
Optional suffix: string
Returns void
update Float4Search playground for updateFloat4
Type declaration
Lambda to Update a vec4 of float in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
x: number
y: number
z: number
w: number
Optional suffix: string
Returns void
update Float ArraySearch playground for updateFloatArray
Type declaration
Lambda to Update an array of float in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
array: Float32Array
Returns void
update IntSearch playground for updateInt
Type declaration
Lambda to Update a int a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
x: number
Optional suffix: string
Returns void
update Int2Search playground for updateInt2
Type declaration
Lambda to Update a vec2 of int in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
x: number
y: number
Optional suffix: string
Returns void
update Int3Search playground for updateInt3
Type declaration
Lambda to Update a vec3 of int in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
x: number
y: number
z: number
Optional suffix: string
Returns void
update Int4Search playground for updateInt4
Type declaration
Lambda to Update a vec4 of int in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
x: number
y: number
z: number
w: number
Optional suffix: string
Returns void
update Int ArraySearch playground for updateIntArray
Type declaration
Lambda to Update an array of number in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
array: Int32Array
Returns void
update MatricesSearch playground for updateMatrices
Type declaration
Lambda to Update an array of 4x4 Matrix in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
mat: Float32Array
Returns void
update MatrixSearch playground for updateMatrix
Type declaration
Lambda to Update a 4x4 Matrix in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
mat: IMatrixLike
Returns void
update Matrix2x2Search playground for updateMatrix2x2
Type declaration
Lambda to Update a 2x2 Matrix in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
matrix: Float32Array
Returns void
update Matrix3x3Search playground for updateMatrix3x3
Type declaration
Lambda to Update a 3x3 Matrix in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
matrix: Float32Array
Returns void
updateUIntSearch playground for updateUInt
Type declaration
Lambda to Update a unsigned int a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
x: number
Optional suffix: string
Returns void
updateUInt2Search playground for updateUInt2
Type declaration
Lambda to Update a vec2 of unsigned int in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
x: number
y: number
Optional suffix: string
Returns void
updateUInt3Search playground for updateUInt3
Type declaration
Lambda to Update a vec3 of unsigned int in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
x: number
y: number
z: number
Optional suffix: string
Returns void
updateUInt4Search playground for updateUInt4
Type declaration
Lambda to Update a vec4 of unsigned int in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
x: number
y: number
z: number
w: number
Optional suffix: string
Returns void
updateUInt ArraySearch playground for updateUIntArray
Type declaration
Lambda to Update an array of number in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
array: Uint32Array
Returns void
update Vector3Search playground for updateVector3
Type declaration
Lambda to Update vec3 of float from a Vector in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
vector: IVector3Like
Returns void
update Vector4Search playground for updateVector4
Type declaration
Lambda to Update vec4 of float from a Vector in a uniform buffer. This is dynamic to allow compat with webgl 1 and 2. You will need to pass the name of the uniform as well as the value.
Parameters
name: string
vector: IVector4Like
Returns void
Accessors
current Effect
is Sync
Indicates if the WebGL underlying uniform buffer is in sync with the javascript cache data.
Returns boolean
name
Gets the name of this buffer
Returns string
use Ubo
Indicates if the buffer is using the WebGL2 UBO implementation, or just falling back on setUniformXXX calls.
Returns boolean
Methods
add Color3Search playground for addColor3
Adds a vec3 to the uniform buffer.
Parameters
name: string
Name of the uniform, as used in the uniform block in the shader.
color: IColor3Like
Define the vec3 from a Color
Returns void
add Color4Search playground for addColor4
Adds a vec4 to the uniform buffer.
Parameters
name: string
Name of the uniform, as used in the uniform block in the shader.
color: IColor3Like
Define the rgb components from a Color
alpha: number
Define the a component of the vec4
Returns void
add Float2Search playground for addFloat2
Adds a vec2 to the uniform buffer.
Parameters
name: string
Name of the uniform, as used in the uniform block in the shader.
x: number
Define the x component value of the vec2
y: number
Define the y component value of the vec2
Returns void
add Float3Search playground for addFloat3
Adds a vec3 to the uniform buffer.
Parameters
name: string
Name of the uniform, as used in the uniform block in the shader.
x: number
Define the x component value of the vec3
y: number
Define the y component value of the vec3
z: number
Define the z component value of the vec3
Returns void
add MatrixSearch playground for addMatrix
Adds a Matrix 4x4 to the uniform buffer.
Parameters
name: string
Name of the uniform, as used in the uniform block in the shader.
mat: IMatrixLike
A 4x4 matrix.
Returns void
add Matrix2x2Search playground for addMatrix2x2
Adds a Matrix 2x2 to the uniform buffer.
Parameters
name: string
Name of the uniform, as used in the uniform block in the shader.
Returns void
add Matrix3x3Search playground for addMatrix3x3
Adds a Matrix 3x3 to the uniform buffer.
Parameters
name: string
Name of the uniform, as used in the uniform block in the shader.
Returns void
add UniformSearch playground for addUniform
Adds an uniform in the buffer. Warning : the subsequents calls of this function must be in the same order as declared in the shader for the layout to be correct ! The addUniform function only handles types like float, vec2, vec3, vec4, mat4, meaning size=1,2,3,4 or 16. It does not handle struct types.
Parameters
name: string
Name of the uniform, as used in the uniform block in the shader.
size: number | number[]
Data size, or data directly.
Optional arraySize: number
The number of elements in the array, 0 if not an array.
Returns void
add Vector3Search playground for addVector3
Adds a vec3 to the uniform buffer.
Parameters
name: string
Name of the uniform, as used in the uniform block in the shader.
vector: IVector3Like
Define the vec3 components from a Vector
Returns void
bind To EffectSearch playground for bindToEffect
Associates an effect to this uniform buffer
Parameters
effect: Effect
Define the effect to associate the buffer to
name: string
Name of the uniform block in the shader.
Returns void
bind Uniform BufferSearch playground for bindUniformBuffer
Binds the current (GPU) buffer to the effect
Returns void
createSearch playground for create
Effectively creates the WebGL Uniform Buffer, once layout is completed with
addUniform
.Returns void
disposeSearch playground for dispose
Disposes the uniform buffer.
Returns void
get BufferSearch playground for getBuffer
The underlying WebGL Uniform buffer.
Returns Nullable<DataBuffer>
the webgl buffer
get DataSearch playground for getData
The data cache on JS side.
Returns Float32Array
the underlying data as a float array
is DynamicSearch playground for isDynamic
Indicates if the WebGL underlying uniform buffer is dynamic. Also, a dynamic UniformBuffer will disable cache verification and always update the underlying WebGL uniform buffer to the GPU.
Returns boolean
if Dynamic, otherwise false
set Data BufferSearch playground for setDataBuffer
Sets the current state of the class (_bufferIndex, _buffer) to point to the data buffer passed in parameter if this buffer is one of the buffers handled by the class (meaning if it can be found in the _buffers array) This method is meant to be able to update a buffer at any time: just call setDataBuffer to set the class in the right state, call some updateXXX methods and then call udpate() => that will update the GPU buffer on the graphic card
Parameters
dataBuffer: DataBuffer
buffer to look for
Returns boolean
true if the buffer has been found and the class internal state points to it, else false
set TextureSearch playground for setTexture
Sets a sampler uniform on the effect.
Parameters
name: string
Define the name of the sampler.
texture: Nullable<ThinTexture>
Define the texture to set in the sampler
Returns void
unbind EffectSearch playground for unbindEffect
Dissociates the current effect from this uniform buffer
Returns void
updateSearch playground for update
Updates the WebGL Uniform Buffer on the GPU. If the
dynamic
flag is set to true, no cache comparison is done. Otherwise, the buffer will be updated only if the cache differs.Returns void
update UniformSearch playground for updateUniform
Updates the value of an uniform. The
update
method must be called afterwards to make it effective in the GPU.Parameters
uniformName: string
Define the name of the uniform, as used in the uniform block in the shader.
data: FloatArray
Define the flattened data
size: number
Define the size of the data.
Returns void
update Uniform ArraySearch playground for updateUniformArray
Updates the value of an uniform. The
update
method must be called afterwards to make it effective in the GPU.Parameters
uniformName: string
Define the name of the uniform, as used in the uniform block in the shader.
data: FloatArray
Define the flattened data
size: number
Define the size of the data.
Returns void
update Uniform DirectlySearch playground for updateUniformDirectly
Directly updates the value of the uniform in the cache AND on the GPU.
Parameters
uniformName: string
Define the name of the uniform, as used in the uniform block in the shader.
data: FloatArray
Define the flattened data
Returns void
Uniform buffer objects.
Handles blocks of uniform on the GPU.
If WebGL 2 is not available, this class falls back on traditional setUniformXXX calls.
For more information, please refer to : https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object