Skip to main content
Version: Phaser v4.0.0

FilterMask

A RenderNode that renders the Mask filter effect, used to selectively show or hide regions of a Game Object using a mask texture.

The mask is sourced from a Phaser.Filters.Mask controller, which can provide either a static GL texture or a dynamically rendered Game Object as the mask. When a mask Game Object is used, this node will re-render it into a texture each frame if autoUpdate is enabled, or when needsUpdate is flagged. The mask can optionally be inverted so that masked areas are revealed instead of hidden.

This node binds the source image to texture unit 0 and the mask texture to texture unit 1, then passes the invert flag to the fragment shader to control mask polarity.

See Phaser.Filters.Mask.

Constructor

new FilterMask(manager)

Parameters

nametypeoptionaldescription
managerPhaser.Renderer.WebGL.RenderNodes.RenderNodeManagerNoThe manager that owns this RenderNode.

Scope: static

Extends

Phaser.Renderer.WebGL.RenderNodes.BaseFilterShader

Source: src/renderer/webgl/renderNodes/filters/FilterMask.js#L12
Since: 4.0.0

Inherited Methods

From Phaser.Renderer.WebGL.RenderNodes.BaseFilterShader:

From Phaser.Renderer.WebGL.RenderNodes.RenderNode:


Public Methods

setupTextures

<instance> setupTextures(controller, textures, drawingContext)

Description:

Prepares the texture slots required by the mask filter shader.

Texture unit 0 is the source image (bound by the base class). This method assigns the mask GL texture to unit 1. If the controller has a mask Game Object and either autoUpdate or needsUpdate is set, the dynamic texture is re-rendered at the current drawing context dimensions before being bound.

Parameters:

nametypeoptionaldescription
controllerPhaser.Filters.MaskNoThe filter controller providing the mask texture and update flags.
texturesArray.<WebGLTexture>NoThe texture array to populate. The mask texture is written to index 1.
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context, used to determine the dimensions for dynamic texture updates.

Overrides: Phaser.Renderer.WebGL.RenderNodes.BaseFilterShader#setupTextures

Source: src/renderer/webgl/renderNodes/filters/FilterMask.js#L45
Since: 4.0.0


setupUniforms

<instance> setupUniforms(controller, drawingContext)

Description:

Sets the shader uniforms required by the mask filter.

Binds the uMaskSampler uniform to texture unit 1 so the fragment shader samples from the mask texture, and passes the invert boolean flag to control whether the mask is applied normally or inverted.

Parameters:

nametypeoptionaldescription
controllerPhaser.Filters.MaskNoThe filter controller providing the invert flag.
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.

Overrides: Phaser.Renderer.WebGL.RenderNodes.BaseFilterShader#setupUniforms

Source: src/renderer/webgl/renderNodes/filters/FilterMask.js#L72
Since: 4.0.0


Inherited Members

From Phaser.Renderer.WebGL.RenderNodes.BaseFilterShader:

From Phaser.Renderer.WebGL.RenderNodes.RenderNode: