PIXI.UniformGroup

class UniformGroup

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

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.

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.
// ubo in shader:
uniform myCoolData { // declaring a ubo..
mat4 uCoolMatrix;
float uFloatyMcFloatFace


// a new uniform buffer object..
const myCoolData = new UniformBufferGroup({
  uCoolMatrix: new Matrix(),
  uFloatyMcFloatFace: 23,
}}

// build a shader...
const shader = Shader.from(srcVert, srcFrag, {
  myCoolData // name matches the ubo name in the shader. will be processed accordingly.
})

Constructor


new PIXI.UniformGroup(uniforms: object | Buffer, isStatic: boolean, isUbo: boolean) → {}
Parameters:
Name Type Attributes Description
uniforms object | Buffer

<optional>

Custom uniforms to use to augment the built-in ones. Or a pixi buffer.

isStatic boolean

<optional>

Uniforms wont be changed after creation.

isUbo boolean

<optional>

If true, will treat this uniform group as a uniform buffer object.

Summary


Properties from UniformGroup

boolean
group = true
boolean
static

Flag for if uniforms wont be changed after creation.

boolean
ubo

Flags whether this group is treated like a uniform buffer object.

object
uniforms
number
protected dirtyId
number
protected id

Methods from UniformGroup

Public Properties


group UniformGroup.ts:58
group: boolean = true

Its a group and not a single uniforms.

static UniformGroup.ts:77
static: boolean

Flag for if uniforms wont be changed after creation.

ubo UniformGroup.ts:80
ubo: boolean

Flags whether this group is treated like a uniform buffer object.

uniforms UniformGroup.ts:52
uniforms: object

Uniform values

Protected Properties


dirtyId UniformGroup.ts:71
protected dirtyId: number

Dirty version

id UniformGroup.ts:64
protected id: number

unique id

Public Methods


uboFrom UniformGroup.ts:149
static uboFrom(uniforms: Dict | PIXI.Buffer, _static: boolean) → {PIXI.UniformGroup}

A short hand function for creating a static UBO UniformGroup.

Parameters:
Name Type Attributes Description
uniforms Dict<any> | PIXI.Buffer

the ubo item

_static boolean

<optional>

should this be updated each time it is used? defaults to true here!

Returns:
Type Description
PIXI.UniformGroup

Powered by webdoc!