Skip to main content
Version: Phaser v4.0.0

FilterNormalTools

This RenderNode renders the NormalTools filter effect, which processes normal map textures for use in lighting calculations. It transforms normal vectors using a view matrix so they are correctly oriented relative to the camera, enabling accurate directional lighting on normal-mapped Game Objects.

Two optional features can be enabled via the controller: facing power, which raises the dot-product result to a given exponent to sharpen or soften the lighting falloff; and ratio output, which blends the normal contribution against a direction vector and radius to produce a ratio value used by downstream lighting passes.

This node is used internally by Phaser.Filters.NormalTools and should not need to be instantiated directly. See Phaser.Filters.NormalTools.

Constructor

new FilterNormalTools(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/FilterNormalTools.js#L12
Since: 4.0.0

Inherited Methods

From Phaser.Renderer.WebGL.RenderNodes.BaseFilterShader:

From Phaser.Renderer.WebGL.RenderNodes.RenderNode:


Public Methods

setupUniforms

<instance> setupUniforms(controller, drawingContext)

Description:

Sets the WebGL uniform values for the NormalTools shader based on the current controller settings. Always uploads the view matrix as uViewMatrix. If the controller's facingPower differs from the default value of 1, the uFacingPower uniform is also uploaded. If outputRatio is enabled on the controller, the uRatioVector (a 3-component direction vector) and uRatioRadius uniforms are uploaded as well.

Parameters:

nametypeoptionaldescription
controllerPhaser.Filters.NormalToolsNoThe filter controller providing the uniform values.
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.

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

Source: src/renderer/webgl/renderNodes/filters/FilterNormalTools.js#L86
Since: 4.0.0


updateShaderConfig

<instance> updateShaderConfig(controller, drawingContext)

Description:

Updates the shader program configuration based on the current controller settings. Resets the fragment header addition to the base VIEW_MATRIX define, then conditionally appends the FACING_POWER and OUTPUT_RATIO defines — and adjusts the addition name accordingly — so that the correct shader variant is compiled and cached for the active combination of features.

Parameters:

nametypeoptionaldescription
controllerPhaser.Filters.NormalToolsNoThe filter controller providing the current configuration.
drawingContextPhaser.Renderer.WebGL.DrawingContextNoThe current drawing context.

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

Source: src/renderer/webgl/renderNodes/filters/FilterNormalTools.js#L54
Since: 4.0.0


Inherited Members

From Phaser.Renderer.WebGL.RenderNodes.BaseFilterShader:

From Phaser.Renderer.WebGL.RenderNodes.RenderNode: