FilterSampler
A RenderNode that implements the Sampler filter, which reads pixel data from a WebGL framebuffer and delivers it to a callback without applying any visual modifications.
Unlike other filter nodes, FilterSampler does not transform or composite its input. Instead it acts as a snapshot mechanism: it calls renderer.snapshotFramebuffer on the input drawing context's framebuffer and forwards the result to the controller's callback function. The area sampled is determined by the controller's region property. If region is a Phaser.Geom.Rectangle, that rectangular area is captured. If region is a point (an object with x and y but no width), a single pixel is read. If no region is set, the entire framebuffer is sampled.
This node is used internally by the Phaser filter pipeline when a game object or camera requests a framebuffer snapshot via the Sampler filter.
Constructor
new FilterSampler(manager)
Parameters
| name | type | optional | description |
|---|---|---|---|
| manager | Phaser.Renderer.WebGL.RenderNodes.RenderNodeManager | No | The manager that owns this RenderNode. |
Scope: static
Extends
Source: src/renderer/webgl/renderNodes/filters/FilterSampler.js#L10
Since: 4.0.0
Inherited Methods
From Phaser.Renderer.WebGL.RenderNodes.RenderNode:
Public Methods
run
<instance> run(controller, inputDrawingContext, [outputDrawingContext], [padding])
Description:
Samples the input framebuffer and delivers the result to the controller's callback, then returns the input drawing context unchanged.
The method reads pixel data from inputDrawingContext.framebuffer via renderer.snapshotFramebuffer. The sampled region is controlled by controller.region:
-
If
controller.regionis aPhaser.Geom.Rectangle, the rectangulararea defined by its
x,y,width, andheightis captured. -
If
controller.regionis a point (hasxandybut nowidth),a single pixel at that coordinate is read.
-
If
controller.regionis not set, the entire framebuffer is sampled.
The captured data is passed to controller.callback. The input drawing context is returned unmodified; this node does not write to outputDrawingContext.
Parameters:
| name | type | optional | description |
|---|---|---|---|
| controller | Phaser.Filters.Sampler | No | The Sampler filter controller, providing the region to sample and the callback to receive the result. |
| inputDrawingContext | Phaser.Renderer.WebGL.DrawingContext | No | The drawing context whose framebuffer will be sampled. |
| outputDrawingContext | Phaser.Renderer.WebGL.DrawingContext | Yes | The output drawing context. Not used by this node. |
| padding | Phaser.Geom.Rectangle | Yes | Additional padding around the render area. Not used by this node. |
Overrides: Phaser.Renderer.WebGL.RenderNodes.BaseFilter#run
Returns: Phaser.Renderer.WebGL.DrawingContext - The inputDrawingContext, returned unchanged.
Source: src/renderer/webgl/renderNodes/filters/FilterSampler.js#L43
Since: 4.0.0
Inherited Members
From Phaser.Renderer.WebGL.RenderNodes.RenderNode: