Class: UniformGroup<UNIFORMS>
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:82
Uniform group holds uniform map and some ID's for work
UniformGroup has two modes:
1: Normal mode Normal mode will upload the uniforms with individual function calls as required. This is the default mode for WebGL rendering.
2: Uniform buffer mode This mode will treat the uniforms as a uniform buffer. You can pass in either a buffer that you manually handle, or or a generic object that PixiJS will automatically map to a buffer for you. For maximum benefits, make Ubo UniformGroups static, and only update them each frame. This is the only way uniforms can be used with WebGPU.
Rules of UBOs:
- UBOs only work with WebGL2, so make sure you have a fallback!
- Only floats are supported (including vec[2,3,4], mat[2,3,4])
- Samplers cannot be used in ubo's (a GPU limitation)
- You must ensure that the object you pass in exactly matches in the shader ubo structure. Otherwise, weirdness will ensue!
- The name of the ubo object added to the group must match exactly the name of the ubo in the shader.
When declaring your uniform options, you ust parse in the value and the type of the uniform. The types correspond to the WebGPU types
Uniforms can be modified via the classes 'uniforms' property. It will contain all the uniforms declared in the constructor.
// UBO in shader:
uniform myCoolData { // Declaring a UBO...
mat4 uCoolMatrix;
float uFloatyMcFloatFace;
};
// A new Uniform Buffer Object...
const myCoolData = new UniformGroup({
uCoolMatrix: {value:new Matrix(), type: 'mat4<f32>'},
uFloatyMcFloatFace: {value:23, type: 'f32'},
}}
// modify the data
myCoolData.uniforms.uFloatyMcFloatFace = 42;
// Build a shader...
const shader = Shader.from(srcVert, srcFrag, {
myCoolData // Name matches the UBO name in the shader. Will be processed accordingly.
})
Advanced
Type Parameters
UNIFORMS
UNIFORMS extends object = any
Implements
Constructors
Constructor
> new UniformGroup<UNIFORMS>(uniformStructures, options?): UniformGroup<UNIFORMS>
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:135
Create a new Uniform group
Parameters
uniformStructures
UNIFORMS
The structures of the uniform group
options?
The optional parameters of this uniform group
Returns
UniformGroup<UNIFORMS>
Properties
_dirtyId
> _dirtyId: number
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:123
Internal
used to flag if this Uniform groups data is different from what it has stored in its buffer / on the GPU
_resourceId
> _resourceId: number
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:103
Internal
the resource id used internally by the renderer to build bind group keys
Implementation of
BindResource._resourceId
_resourceType
> _resourceType: string
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:98
Internal
a resource type, used to identify how to handle it when its in a bind group / shader resource
Implementation of
BindResource._resourceType
_signature
> readonly _signature: number
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:128
Internal
a signature string generated for internal use
_touched
> _touched: number
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:91
Internal
used internally to know if a uniform group was used in the last render pass
Implementation of
buffer?
> optional buffer?: Buffer
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:111
an underlying buffer that will be uploaded to the GPU when using this UniformGroup
isStatic
> isStatic: boolean
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:116
if true, then you are responsible for when the data is uploaded to the GPU. otherwise, the data is reuploaded each frame.
isUniformGroup
> readonly isUniformGroup: true = true
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:118
used ito identify if this is a uniform group
ubo
> ubo: boolean
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:109
true if it should be used as a uniform buffer object
uid
> readonly uid: number
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:93
a unique id for this uniform group used through the renderer
uniforms
> uniforms: ExtractUniformObject<UNIFORMS>
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:107
the uniforms as an easily accessible map of properties
uniformStructures
> uniformStructures: UNIFORMS
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:105
the structures of the uniform group
defaultOptions
> static defaultOptions: UniformGroupOptions
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:86
The default options used by the uniform group.
Methods
update()
> update(): void
Defined in: node_modules/pixi.js/lib/rendering/renderers/shared/shader/UniformGroup.d.ts:137
Call this if you want the uniform groups data to be uploaded to the GPU only useful if isStatic is true.
Returns
void