Skip to main content
Version: Phaser v4.0.0

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

nametypeoptionaldescription
managerPhaser.Renderer.WebGL.RenderNodes.RenderNodeManagerNoThe manager that owns this RenderNode.

Scope: static

Extends

Phaser.Renderer.WebGL.RenderNodes.BaseFilter

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.region is a Phaser.Geom.Rectangle, the rectangular

    area defined by its x, y, width, and height is captured.

  • If controller.region is a point (has x and y but no width),

    a single pixel at that coordinate is read.

  • If controller.region is 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:

nametypeoptionaldescription
controllerPhaser.Filters.SamplerNoThe Sampler filter controller, providing the region to sample and the callback to receive the result.
inputDrawingContextPhaser.Renderer.WebGL.DrawingContextNoThe drawing context whose framebuffer will be sampled.
outputDrawingContextPhaser.Renderer.WebGL.DrawingContextYesThe output drawing context. Not used by this node.
paddingPhaser.Geom.RectangleYesAdditional 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: