Skip to main content
Version: Phaser v4.0.0

FilterGradientMap

A RenderNode that renders the GradientMap filter effect, which maps the luminosity of each pixel in the source image to a corresponding color from a gradient ramp texture. Darker pixels are mapped to one end of the gradient and brighter pixels to the other, replacing the original colors entirely. This enables stylistic effects such as thermal imaging, night vision, sepia toning, or any arbitrary color grade driven by brightness.

The gradient is defined by a Phaser.Display.ColorRamp attached to the controlling Phaser.Filters.GradientMap filter. The ramp is uploaded as a data texture and sampled in the fragment shader. The shader variant is selected dynamically based on the ramp's band tree depth, so the program is recompiled when the ramp structure changes.

See Phaser.Filters.GradientMap.

Constructor

new FilterGradientMap(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/FilterGradientMap.js#L13
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:

Binds the textures required by the gradient map shader. The ramp data texture, which encodes the gradient color lookup, is assigned to texture slot 1. Slot 0 is reserved for the source render texture and is handled by the base class.

Parameters:

nametypeoptionaldescription
controllerPhaser.Filters.GradientMapNoThe filter controller providing the ramp data.
texturesArray.<WebGLTexture>NoThe texture array to populate for this draw call.
_drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context. Unused by this method.

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

Source: src/renderer/webgl/renderNodes/filters/FilterGradientMap.js#L55
Since: 4.0.0


setupUniforms

<instance> setupUniforms(controller, _drawingContext)

Description:

Sets all shader uniforms required by the gradient map effect. This includes the ramp texture index, the ramp's data texture resolution and first-band offset (used to address the correct rows in a shared ramp atlas), the dither toggle, the unpremultiply flag, the tint color and its blend factor, and the overall alpha value.

Parameters:

nametypeoptionaldescription
controllerPhaser.Filters.GradientMapNoThe filter controller providing uniform values.
_drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context. Unused by this method.

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

Source: src/renderer/webgl/renderNodes/filters/FilterGradientMap.js#L73
Since: 4.0.0


updateShaderConfig

<instance> updateShaderConfig(controller, _drawingContext)

Description:

Updates the shader program configuration to match the current ramp's band tree depth. The RAMP shader addition's name is set to RAMP_<depth> so the program manager can cache and retrieve the correct variant, and the BAND_TREE_DEPTH preprocessor define in the fragment shader header is rewritten accordingly. This causes the program to be recompiled whenever the ramp structure changes.

Parameters:

nametypeoptionaldescription
controllerPhaser.Filters.GradientMapNoThe filter controller whose ramp provides the current band tree depth.
_drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context. Unused by this method.

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

Source: src/renderer/webgl/renderNodes/filters/FilterGradientMap.js#L101
Since: 4.0.0


Inherited Members

From Phaser.Renderer.WebGL.RenderNodes.BaseFilterShader:

From Phaser.Renderer.WebGL.RenderNodes.RenderNode: