Skip to main content
Version: Phaser v3.88.2

BitmapMaskPipeline

The Bitmap Mask Pipeline handles all of the bitmap mask rendering in WebGL for applying

alpha masks to Game Objects. It works by sampling two texture on the fragment shader and

using the fragments alpha to clip the region.

The fragment shader it uses can be found in shaders/src/BitmapMask.frag.

The vertex shader it uses can be found in shaders/src/BitmapMask.vert.

The default shader attributes for this pipeline are:

inPosition (vec2, offset 0)

The default shader uniforms for this pipeline are:

uResolution (vec2)

uMainSampler (sampler2D)

uMaskSampler (sampler2D)

uInvertMaskAlpha (bool)

Constructor

new BitmapMaskPipeline(config)

Parameters

nametypeoptionaldescription
configPhaser.Types.Renderer.WebGL.WebGLPipelineConfigNoThe configuration options for this pipeline.

Scope: static

Extends

Phaser.Renderer.WebGL.WebGLPipeline

Source: src/renderer/webgl/pipelines/BitmapMaskPipeline.js#L15
Since: 3.0.0

Inherited Methods

From Phaser.Events.EventEmitter:

From Phaser.Renderer.WebGL.WebGLPipeline:


Public Methods

beginMask

<instance> beginMask(mask, maskedObject, camera)

Description:

Binds necessary resources and renders the mask to a separated framebuffer.

The framebuffer for the masked object is also bound for further use.

Parameters:

nametypeoptionaldescription
maskPhaser.Display.Masks.BitmapMaskNoThe BitmapMask instance that called beginMask.
maskedObjectPhaser.GameObjects.GameObjectNoGameObject masked by the mask GameObject.
cameraPhaser.Cameras.Scene2D.CameraNoThe camera rendering the current mask.

Source: src/renderer/webgl/pipelines/BitmapMaskPipeline.js#L81
Since: 3.0.0


endMask

<instance> endMask(mask, camera, [renderTarget])

Description:

The masked game objects framebuffer is unbound and its 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:

nametypeoptionaldescription
maskPhaser.Display.Masks.BitmapMaskNoThe BitmapMask instance that called endMask.
cameraPhaser.Cameras.Scene2D.CameraNoThe Camera to render to.
renderTargetPhaser.Renderer.WebGL.RenderTargetYesOptional WebGL RenderTarget.

Source: src/renderer/webgl/pipelines/BitmapMaskPipeline.js#L97
Since: 3.0.0


Inherited Members

From Phaser.Renderer.WebGL.WebGLPipeline: