CombineColorMatrix
The CombineColorMatrix Filter controller.
This filter combines color channels from two textures: a base input and a secondary transfer texture. Each source is transformed independently by its own ColorMatrix (colorMatrixSelf and colorMatrixTransfer), and the results are then blended per-channel using configurable addition weights (additions) and multiplication weights (multiplications). This makes it suitable for a wide range of compositing effects, though its primary use is alpha channel manipulation — for example, using a greyscale transfer texture as a soft mask or applying a brightness-derived alpha to the base image. Use setupAlphaTransfer to configure the matrices and weights for common alpha-transfer patterns, or set the colorMatrixSelf, colorMatrixTransfer, additions, and multiplications properties directly for custom effects.
A CombineColorMatrix filter is added to a Camera via the FilterList component:
const camera = this.cameras.main;
camera.filters.internal.addCombineColorMatrix();
camera.filters.external.addCombineColorMatrix();
Constructor
new CombineColorMatrix(camera, [texture])
Parameters
| name | type | optional | default | description |
|---|---|---|---|---|
| camera | Phaser.Cameras.Scene2D.Camera | No | The camera that owns this filter. | |
| texture | string | Phaser.Textures.Texture | Yes | "'__WHITE'" | The texture or texture key to use for the transfer texture. |
Scope: static
Extends
Source: src/filters/CombineColorMatrix.js#L11
Since: 4.0.0
Inherited Members
From Phaser.Filters.Controller:
Public Members
additions
additions: Array.<number>
Description:
Weight of addition for each channel (R, G, B, A). The final output includes values from the self and transfer matrices added together; those values are multiplied by this array. So values of 1 are kept, while values of 0 are discarded.
By default, RGB values are added together in the final output.
Source: src/filters/CombineColorMatrix.js#L77
Since: 4.0.0
colorMatrixSelf
colorMatrixSelf: Phaser.Display.ColorMatrix
Description:
The color matrix which contributes values from the base input.
Source: src/filters/CombineColorMatrix.js#L59
Since: 4.0.0
colorMatrixTransfer
colorMatrixTransfer: Phaser.Display.ColorMatrix
Description:
The color matrix which contributes values from the transfer texture.
Source: src/filters/CombineColorMatrix.js#L68
Since: 4.0.0
glTexture
glTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper
Description:
The transfer texture used to provide extra channels.
Source: src/filters/CombineColorMatrix.js#L50
Since: 4.0.0
multiplications
multiplications: Array.<number>
Description:
Weight of multiplication for each channel (R, G, B, A). The final output includes values from the self and transfer matrices multiplied together; those values are multiplied by this array. So values of 1 are kept, while values of 0 are discarded.
By default, alpha values are multiplied together in the final output.
Source: src/filters/CombineColorMatrix.js#L92
Since: 4.0.0
Inherited Methods
From Phaser.Filters.Controller:
Public Methods
destroy
<instance> destroy()
Description:
Destroys this filter, releasing all references and resources.
Overrides: Phaser.Filters.Controller#destroy
Source: src/filters/CombineColorMatrix.js#L178
Since: 4.0.0
setTexture
<instance> setTexture(texture)
Description:
Set the transfer texture. This is used as an extra channel source, transferring its data into the filtered image.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| texture | string | Phaser.Textures.Texture | No | The texture or texture key to use for the transfer texture. |
Returns: Phaser.Filters.CombineColorMatrix - This filter instance.
Source: src/filters/CombineColorMatrix.js#L110
Since: 4.0.0
setupAlphaTransfer
<instance> setupAlphaTransfer([colorSelf], [colorTransfer], [brightnessToAlphaSelf], [brightnessToAlphaTransfer], [brightnessToAlphaInverseSelf], [brightnessToAlphaInverseTransfer])
Description:
Resets both color matrices and the additions and multiplications weighting arrays, then applies a preset configuration for alpha transfer — a common use case for this filter. In the preset, RGB channels are combined by addition and the alpha channel is combined by multiplication. The boolean parameters control which color and brightness-to-alpha transformations are applied to each source before blending.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| colorSelf | boolean | Yes | Whether to keep color from the base image. |
| colorTransfer | boolean | Yes | Whether to keep color from the transfer texture. |
| brightnessToAlphaSelf | boolean | Yes | Whether to determine the base alpha from the base brightness. |
| brightnessToAlphaTransfer | boolean | Yes | Whether to determine the transfer alpha from the transfer brightness. |
| brightnessToAlphaInverseSelf | boolean | Yes | Whether to determine the base alpha from the base brightness, inverted. This overrides brightnessToAlphaSelf. |
| brightnessToAlphaInverseTransfer | boolean | Yes | Whether to determine the transfer alpha from the transfer brightness, inverted. This overrides brightnessToAlphaTransfer. |
Returns: Phaser.Filters.CombineColorMatrix - This filter instance.
Source: src/filters/CombineColorMatrix.js#L132
Since: 4.0.0