Class: BitmapMaskPipeline

Phaser.Renderer.WebGL.Pipelines. BitmapMaskPipeline

BitmapMaskPipeline handles all bitmap masking rendering in WebGL. It works by using sampling two texture on the fragment shader and using the fragment's alpha to clip the region. The config properties are:

  • game: Current game instance.
  • renderer: Current WebGL renderer.
  • topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES.
           Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants).
  • vertShader: Source for vertex shader as a string.
  • fragShader: Source for fragment shader as a string.
  • vertexCapacity: The amount of vertices that shall be allocated
  • vertexSize: The size of a single vertex in bytes.

new BitmapMaskPipeline(config)

Parameters:
Name Type Description
config object

Used for overriding shader an pipeline properties if extending this pipeline.

Since: 3.0.0
Source: src/renderer/webgl/pipelines/BitmapMaskPipeline.js (Line 13)

Extends

Members


active :boolean

Indicates if the current pipeline is active or not for this frame only. Reset in the onRender method.

Type:
  • boolean
Since: 3.10.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 230)

attributes :object

Array of objects that describe the vertex attributes

Type:
  • object
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 174)

bytes :Uint8Array

Uint8 view to the vertex raw buffer. Used for uploading vertex buffer resources to the GPU.

Type:
  • Uint8Array
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 201)

flushLocked :boolean

Indicates if the current pipeline is flushing the contents to the GPU. When the variable is set the flush function will be locked.

Type:
  • boolean
Since: 3.1.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 220)

game :Phaser.Game

The Game which owns this WebGL Pipeline.

Type:
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 65)

gl :WebGLRenderingContext

The WebGL context this WebGL Pipeline uses.

Type:
  • WebGLRenderingContext
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 110)

height :number

Height of the current viewport

Type:
  • number
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 101)

maxQuads :number

Size of the batch.

Type:
  • number
Since: 3.0.0
Default Value:
  • 1
Source: src/renderer/webgl/pipelines/BitmapMaskPipeline.js (Line 79)

name :string

Name of the Pipeline. Used for identifying

Type:
  • string
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 56)

program :WebGLProgram

The handle to a WebGL program

Type:
  • WebGLProgram
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 165)

renderer :Phaser.Renderer.WebGL.WebGLRenderer

The WebGL Renderer which owns this WebGL Pipeline.

Type:
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 138)

resolution :number

Used to store the current game resolution

Type:
  • number
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 83)

resolutionDirty :boolean

Dirty flag to check if resolution properties need to be updated on the masking shader.

Type:
  • boolean
Since: 3.0.0
Default Value:
  • true
Source: src/renderer/webgl/pipelines/BitmapMaskPipeline.js (Line 89)

topology :integer

The primitive topology which the pipeline will use to submit draw calls

Type:
  • integer
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 192)

vertexBuffer :WebGLBuffer

The handle to a WebGL vertex buffer object.

Type:
  • WebGLBuffer
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 156)

vertexCapacity :integer

The limit of vertices that the pipeline can hold

Type:
  • integer
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 129)

vertexComponentCount :integer

This will store the amount of components of 32 bit length

Type:
  • integer
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 211)

vertexCount :number

How many vertices have been fed to the current pipeline.

Type:
  • number
Since: 3.0.0
Inherited From:
Default Value:
  • 0
Source: src/renderer/webgl/WebGLPipeline.js (Line 119)

vertexData :ArrayBuffer

Raw byte buffer of vertices.

Type:
  • ArrayBuffer
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 147)

vertexSize :integer

The size in bytes of the vertex

Type:
  • integer
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 183)

vertexViewF32 :Float32Array

Float32 view of the array buffer containing the pipeline's vertices.

Type:
  • Float32Array
Since: 3.0.0
Source: src/renderer/webgl/pipelines/BitmapMaskPipeline.js (Line 70)

view :HTMLCanvasElement

The canvas which this WebGL Pipeline renders to.

Type:
  • HTMLCanvasElement
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 74)

width :number

Width of the current viewport

Type:
  • number
Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 92)

Methods


addAttribute(name, size, type, normalized, offset)

Adds a description of vertex attribute to the pipeline

Parameters:
Name Type Description
name string

Name of the vertex attribute

size integer

Vertex component size

type integer

Type of the attribute

normalized boolean

Is the value normalized to a range

offset integer

Byte offset to the beginning of the first element in the vertex

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 254)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

beginMask(mask, maskedObject, camera)

Binds necessary resources and renders the mask to a separated framebuffer. The framebuffer for the masked object is also bound for further use.

Parameters:
Name Type Description
mask Phaser.GameObjects.GameObject

GameObject used as mask.

maskedObject Phaser.GameObjects.GameObject

GameObject masked by the mask GameObject.

camera Phaser.Cameras.Scene2D.Camera

[description]

Since: 3.0.0
Source: src/renderer/webgl/pipelines/BitmapMaskPipeline.js (Line 147)

bind()

Binds the pipeline resources, including programs, vertex buffers and binds attributes

Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 315)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

boot()

Called when the Game has fully booted and the Renderer has finished setting up.

By this stage all Game level systems are now in place and you can perform any final tasks that the pipeline may need that relied on game systems such as the Texture Manager.

Since: 3.11.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 241)

destroy()

Removes all object references in this WebGL Pipeline and removes its program from the WebGL context.

Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 450)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

endMask(mask)

The masked game object's framebuffer is unbound and it's texture is bound together with the mask texture and the mask shader and a draw call with a single quad is processed. Here is where the masking effect is applied.

Parameters:
Name Type Description
mask Phaser.GameObjects.GameObject

GameObject used as a mask.

Since: 3.0.0
Source: src/renderer/webgl/pipelines/BitmapMaskPipeline.js (Line 187)

flush()

Uploads the vertex data and emits a draw call for the current batch of vertices.

Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 415)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

onBind()

Called every time the pipeline needs to be used. It binds all necessary resources.

Since: 3.0.0
Overrides:
Source: src/renderer/webgl/pipelines/BitmapMaskPipeline.js (Line 101)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

onPostRender()

Called after each frame has been completely rendered and snapshots have been taken.

Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 401)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

onPreRender()

Called before each frame is rendered, but after the canvas has been cleared.

Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 370)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

onRender(scene, camera)

Called before a Scene's Camera is rendered.

Parameters:
Name Type Description
scene Phaser.Scene

The Scene being rendered.

camera Phaser.Cameras.Scene2D.Camera

The Scene Camera being rendered with.

Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 384)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

resize(width, height, resolution)

[description]

Parameters:
Name Type Description
width number

[description]

height number

[description]

resolution number

[description]

Since: 3.0.0
Overrides:
Source: src/renderer/webgl/pipelines/BitmapMaskPipeline.js (Line 128)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setFloat1(name, x)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

x number

The new value of the float uniform.

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 472)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setFloat1v(name, arr)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

arr Float32Array

The new value to be used for the uniform variable.

Since: 3.13.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 550)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setFloat2(name, x, y)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

x number

The new X component of the vec2 uniform.

y number

The new Y component of the vec2 uniform.

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 490)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setFloat2v(name, arr)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

arr Float32Array

The new value to be used for the uniform variable.

Since: 3.13.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 568)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setFloat3(name, x, y, z)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

x number

The new X component of the vec3 uniform.

y number

The new Y component of the vec3 uniform.

z number

The new Z component of the vec3 uniform.

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 509)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setFloat3v(name, arr)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

arr Float32Array

The new value to be used for the uniform variable.

Since: 3.13.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 586)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setFloat4(name, x, y, z, w)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

x number

X component of the uniform

y number

Y component of the uniform

z number

Z component of the uniform

w number

W component of the uniform

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 529)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setFloat4v(name, arr)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

arr Float32Array

The new value to be used for the uniform variable.

Since: 3.13.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 604)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setInt1(name, x)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

x integer

The new value of the int uniform.

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 622)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setInt2(name, x, y)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

x integer

The new X component of the ivec2 uniform.

y integer

The new Y component of the ivec2 uniform.

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 640)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setInt3(name, x, y, z)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

x integer

The new X component of the ivec3 uniform.

y integer

The new Y component of the ivec3 uniform.

z integer

The new Z component of the ivec3 uniform.

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 659)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setInt4(name, x, y, z, w)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

x integer

X component of the uniform

y integer

Y component of the uniform

z integer

Z component of the uniform

w integer

W component of the uniform

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 679)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setMatrix2(name, transpose, matrix)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

transpose boolean

Whether to transpose the matrix. Should be false.

matrix Float32Array

The new values for the mat2 uniform.

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 700)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setMatrix3(name, transpose, matrix)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

transpose boolean

Whether to transpose the matrix. Should be false.

matrix Float32Array

The new values for the mat3 uniform.

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 719)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

setMatrix4(name, transpose, matrix)

Set a uniform value of the current pipeline program.

Parameters:
Name Type Description
name string

The name of the uniform to look-up and modify.

transpose boolean

Should the matrix be transpose

matrix Float32Array

Matrix data

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 738)
Returns:

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

shouldFlush()

Check if the current batch of vertices is full.

Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 281)
Returns:

true if the current batch should be flushed, otherwise false.

Type
boolean