BaseFilter
The base class for all WebGL post-processing filters in Phaser.
Filters are render nodes that apply visual effects to a WebGL texture by processing an input drawing context and producing an output drawing context. They are managed by a Phaser.Filters.Controller, which chains multiple filters together so that each filter's output becomes the next filter's input. Examples of filters include blur, glow, bloom, and color correction.
This class should not be instantiated directly. Instead, extend it to create a custom filter that overrides the run method.
Constructor
new BaseFilter(name, manager)
Parameters
| name | type | optional | description |
|---|---|---|---|
| name | string | No | The name of the filter. |
| manager | Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager | No | The manager that owns this filter. |
Scope: static
Extends
Source: src/renderer/webgl/renderNodes/filters/BaseFilter.js#L10
Since: 4.0.0
Inherited Methods
From Phaser.Renderer.WebGL.RenderNodes.RenderNode:
Public Methods
run
<instance> run(controller, inputDrawingContext, [outputDrawingContext], [padding])
Description:
Runs the filter, processing the input drawing context and returning a drawing context containing the output texture.
This base implementation does nothing and is intended to be overridden by subclasses. Each subclass should apply its specific visual effect (for example, blur or glow) by writing to the output drawing context using WebGL shader programs.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| controller | Phaser.Filters.Controller | No | The filter controller. |
| inputDrawingContext | Phaser.Renderer.WebGL.DrawingContext | No | The drawing context containing the input texture. This is either the initial render, or the output of the previous filter. This will be released during the run process, and can no longer be used. |
| outputDrawingContext | Phaser.Renderer.WebGL.DrawingContext | Yes | The drawing context where the output texture will be drawn. If not specified, a new drawing context will be generated. Generally, this parameter is used for the last filter in a chain, so the output texture is drawn to the main framebuffer. |
| padding | Phaser.Geom.Rectangle | Yes | The padding to add to the input texture to create the output texture. If not specified, the controller is used to get the padding. This should be undefined for internal filters, so the controller will expand textures as needed; and defined as the negative padding of the previous filter for external filters, so the texture will shrink to the correct size. |
Overrides: Phaser.Renderer.WebGL.RenderNodes.RenderNode#run
Returns: Phaser.Renderer.WebGL.DrawingContext - The drawing context containing the output texture.
Source: src/renderer/webgl/renderNodes/filters/BaseFilter.js#L40
Since: 4.0.0
Inherited Members
From Phaser.Renderer.WebGL.RenderNodes.RenderNode: