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

[description]

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

gl :WebGLRenderingContext

[description]

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

[description]

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

[description]

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 314)
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()

[description]

Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 447)
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 412)
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()

[description]

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

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

onPreRender()

[description]

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

This WebGLPipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

onRender(scene, camera)

[description]

Parameters:
Name Type Description
scene Phaser.Scene

[description]

camera Phaser.Cameras.Scene2D.Camera

[description]

Since: 3.0.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 381)
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

[description]

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 469)
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 547)
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

[description]

y number

[description]

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 487)
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 565)
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

[description]

y number

[description]

z number

[description]

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 506)
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 583)
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 526)
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 601)
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

[description]

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 619)
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

[description]

y integer

[description]

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 637)
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

[description]

y integer

[description]

z integer

[description]

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 656)
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 676)
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

[description]

matrix Float32Array

[description]

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 697)
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

[description]

matrix Float32Array

[description]

Since: 3.2.0
Inherited From:
Source: src/renderer/webgl/WebGLPipeline.js (Line 716)
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 735)
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:

[description]

Type
boolean