Class: PipelineManager

Phaser.Renderer.WebGL. PipelineManager

The Pipeline Manager is responsible for the creation, activation, running and destruction of WebGL Pipelines and Post FX Pipelines in Phaser 3.

The WebGLRenderer owns a single instance of the Pipeline Manager, which you can access via the WebGLRenderer.pipelines property.

By default, there are 8 pipelines installed into the Pipeline Manager when Phaser boots:

  1. The Multi Pipeline. Responsible for all multi-texture rendering, i.e. Sprites and Tilemaps.
  2. The Graphics Pipeline. Responsible for rendering Graphics and Shape objects.
  3. The Rope Pipeline. Responsible for rendering the Rope Game Object.
  4. The Light Pipeline. Responsible for rendering the Light Game Object.
  5. The Point Light Pipeline. Responsible for rendering the Point Light Game Object.
  6. The Single Pipeline. Responsible for rendering Game Objects that explicitly require one bound texture.
  7. The Bitmap Mask Pipeline. Responsible for Bitmap Mask rendering.
  8. The Utility Pipeline. Responsible for providing lots of handy texture manipulation functions.

You can add your own custom pipeline via the PipelineManager.add method. Pipelines are identified by unique string-based keys.


new PipelineManager(renderer)

Parameters:
Name Type Description
renderer Phaser.Renderer.WebGL.WebGLRenderer

A reference to the WebGL Renderer that owns this Pipeline Manager.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 21)

Members


BITMAPMASK_PIPELINE :Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline

A constant-style reference to the Bitmap Mask Pipeline Instance.

This is the default Phaser 3 mask pipeline and is used Game Objects using a Bitmap Mask. This property is set during the boot method.

Type:
Since: 3.50.0
Default Value:
  • null
Source: src/renderer/webgl/PipelineManager.js (Line 149)

classes :Phaser.Structs.Map.<string, Class>

This map stores all pipeline classes available in this manager.

The Utility Class must always come first.

Type:
Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 74)

current :Phaser.Renderer.WebGL.WebGLPipeline

Current pipeline in use by the WebGLRenderer.

Type:
Since: 3.50.0
Default Value:
  • null
Source: src/renderer/webgl/PipelineManager.js (Line 114)

fullFrame1 :Phaser.Renderer.WebGL.RenderTarget

A reference to the Full Frame 1 Render Target that belongs to the Utility Pipeline. This property is set during the boot method.

This Render Target is the full size of the renderer.

You can use this directly in Post FX Pipelines for multi-target effects. However, be aware that these targets are shared between all post fx pipelines.

Type:
Since: 3.50.0
Default Value:
  • null
Source: src/renderer/webgl/PipelineManager.js (Line 172)

fullFrame2 :Phaser.Renderer.WebGL.RenderTarget

A reference to the Full Frame 2 Render Target that belongs to the Utility Pipeline. This property is set during the boot method.

This Render Target is the full size of the renderer.

You can use this directly in Post FX Pipelines for multi-target effects. However, be aware that these targets are shared between all post fx pipelines.

Type:
Since: 3.50.0
Default Value:
  • null
Source: src/renderer/webgl/PipelineManager.js (Line 188)

game :Phaser.Game

A reference to the Game instance.

Type:
Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 56)

halfFrame1 :Phaser.Renderer.WebGL.RenderTarget

A reference to the Half Frame 1 Render Target that belongs to the Utility Pipeline. This property is set during the boot method.

This Render Target is half the size of the renderer.

You can use this directly in Post FX Pipelines for multi-target effects. However, be aware that these targets are shared between all post fx pipelines.

Type:
Since: 3.50.0
Default Value:
  • null
Source: src/renderer/webgl/PipelineManager.js (Line 204)

halfFrame2 :Phaser.Renderer.WebGL.RenderTarget

A reference to the Half Frame 2 Render Target that belongs to the Utility Pipeline. This property is set during the boot method.

This Render Target is half the size of the renderer.

You can use this directly in Post FX Pipelines for multi-target effects. However, be aware that these targets are shared between all post fx pipelines.

Type:
Since: 3.50.0
Default Value:
  • null
Source: src/renderer/webgl/PipelineManager.js (Line 220)

MULTI_PIPELINE :Phaser.Renderer.WebGL.Pipelines.MultiPipeline

A constant-style reference to the Multi Pipeline Instance.

This is the default Phaser 3 pipeline and is used by the WebGL Renderer to manage camera effects and more. This property is set during the boot method.

Type:
Since: 3.50.0
Default Value:
  • null
Source: src/renderer/webgl/PipelineManager.js (Line 136)

pipelines :Phaser.Structs.Map.<string, Phaser.Renderer.WebGL.WebGLPipeline>

This map stores all pipeline instances in this manager.

This is populated with the default pipelines in the boot method.

Type:
Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 103)

postPipelineClasses :Phaser.Structs.Map.<string, Class>

This map stores all Post FX Pipeline classes available in this manager.

Type:
Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 94)

previous :Phaser.Renderer.WebGL.WebGLPipeline

The previous WebGLPipeline that was in use.

This is set when clearPipeline is called and restored in rebindPipeline if none is given.

Type:
Since: 3.50.0
Default Value:
  • null
Source: src/renderer/webgl/PipelineManager.js (Line 124)

renderer :Phaser.Renderer.WebGL.WebGLRenderer

A reference to the WebGL Renderer instance.

Type:
Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 65)

UTILITY_PIPELINE :Phaser.Renderer.WebGL.Pipelines.UtilityPipeline

A constant-style reference to the Utility Pipeline Instance.

Type:
Since: 3.50.0
Default Value:
  • null
Source: src/renderer/webgl/PipelineManager.js (Line 162)

Methods


add(name, pipeline)

Adds a pipeline instance to this Pipeline Manager.

The name of the instance must be unique within this manager.

Make sure to pass an instance to this method, not a base class.

For example, you should pass it like this:

this.add('yourName', new CustomPipeline());`

and not like this:

this.add('yourName', CustomPipeline);`

To add a Post Pipeline, see addPostPipeline instead.

Parameters:
Name Type Description
name string

A unique string-based key for the pipeline within the manager.

pipeline Phaser.Renderer.WebGL.WebGLPipeline

A pipeline instance which must extend WebGLPipeline.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 304)
Returns:

The pipeline instance that was passed.

Type
Phaser.Renderer.WebGL.WebGLPipeline

addPostPipeline(name, pipeline)

Adds a Post Pipeline to this Pipeline Manager.

Make sure to pass a base class to this method, not an instance.

For example, you should pass it like this:

this.addPostPipeline('yourName', CustomPipeline);`

and not like this:

this.addPostPipeline('yourName', new CustomPipeline());`

To add a regular pipeline, see the add method instead.

Parameters:
Name Type Description
name string

A unique string-based key for the pipeline within the manager.

pipeline function

A pipeline class which must extend PostFXPipeline.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 370)
Returns:

This Pipeline Manager.

Type
Phaser.Renderer.WebGL.PipelineManager

blendFrames(source1, source2 [, target] [, strength] [, clearAlpha])

Draws the source1 and source2 Render Targets to the target Render Target using a linear blend effect, which is controlled by the strength parameter.

The draw itself is handled by the Utility Pipeline.

Parameters:
Name Type Argument Default Description
source1 Phaser.Renderer.WebGL.RenderTarget

The first source Render Target.

source2 Phaser.Renderer.WebGL.RenderTarget

The second source Render Target.

target Phaser.Renderer.WebGL.RenderTarget <optional>

The target Render Target.

strength number <optional>
1

The strength of the blend.

clearAlpha boolean <optional>
true

Clear the alpha channel when running gl.clear on the target?

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 831)
Returns:

This Pipeline Manager instance.

Type
Phaser.Renderer.WebGL.PipelineManager

blendFramesAdditive(source1, source2 [, target] [, strength] [, clearAlpha])

Draws the source1 and source2 Render Targets to the target Render Target using an additive blend effect, which is controlled by the strength parameter.

The draw itself is handled by the Utility Pipeline.

Parameters:
Name Type Argument Default Description
source1 Phaser.Renderer.WebGL.RenderTarget

The first source Render Target.

source2 Phaser.Renderer.WebGL.RenderTarget

The second source Render Target.

target Phaser.Renderer.WebGL.RenderTarget <optional>

The target Render Target.

strength number <optional>
1

The strength of the blend.

clearAlpha boolean <optional>
true

Clear the alpha channel when running gl.clear on the target?

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 855)
Returns:

This Pipeline Manager instance.

Type
Phaser.Renderer.WebGL.PipelineManager

blitFrame(source, target [, brightness] [, clear] [, clearAlpha] [, eraseMode])

Copy the source Render Target to the target Render Target.

The difference with this copy is that no resizing takes place. If the source Render Target is larger than the target then only a portion the same size as the target dimensions is copied across.

You can optionally set the brightness factor of the copy.

Parameters:
Name Type Argument Default Description
source Phaser.Renderer.WebGL.RenderTarget

The source Render Target.

target Phaser.Renderer.WebGL.RenderTarget

The target Render Target.

brightness number <optional>
1

The brightness value applied to the frame copy.

clear boolean <optional>
true

Clear the target before copying?

clearAlpha boolean <optional>
true

Clear the alpha channel when running gl.clear on the target?

eraseMode boolean <optional>
false

Erase source from target using ERASE Blend Mode?

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 897)
Returns:

This Pipeline Manager instance.

Type
Phaser.Renderer.WebGL.PipelineManager

boot( [pipelineConfig])

Internal boot handler, called by the WebGLRenderer durings its boot process.

Adds all of the default pipelines, based on the game config, and then calls the boot method on each one of them.

Finally, the default pipeline is set.

Parameters:
Name Type Argument Description
pipelineConfig Phaser.Types.Core.PipelineConfig <optional>

The pipeline configuration object as set in the Game Config.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 237)

clear()

Flushes the current pipeline being used and then clears it, along with the the current shader program and vertex buffer from the WebGLRenderer.

Then resets the blend mode to NORMAL.

Call this before jumping to your own gl context handler, and then call rebind when you wish to return control to Phaser again.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 1058)

clearFrame(target [, clearAlpha])

Clears the given Render Target.

Parameters:
Name Type Argument Default Description
target Phaser.Renderer.WebGL.RenderTarget

The Render Target to clear.

clearAlpha boolean <optional>
true

Clear the alpha channel when running gl.clear on the target?

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 879)
Returns:

This Pipeline Manager instance.

Type
Phaser.Renderer.WebGL.PipelineManager

copyFrame(source [, target] [, brightness] [, clear] [, clearAlpha])

Copy the source Render Target to the target Render Target.

You can optionally set the brightness factor of the copy.

The difference between this method and drawFrame is that this method uses a faster copy shader, where only the brightness can be modified. If you need color level manipulation, see drawFrame instead.

The copy itself is handled by the Utility Pipeline.

Parameters:
Name Type Argument Default Description
source Phaser.Renderer.WebGL.RenderTarget

The source Render Target.

target Phaser.Renderer.WebGL.RenderTarget <optional>

The target Render Target.

brightness number <optional>
1

The brightness value applied to the frame copy.

clear boolean <optional>
true

Clear the target before copying?

clearAlpha boolean <optional>
true

Clear the alpha channel when running gl.clear on the target?

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 752)
Returns:

This Pipeline Manager instance.

Type
Phaser.Renderer.WebGL.PipelineManager

copyFrameRect(source, target, x, y, width, height [, clear] [, clearAlpha])

Binds the source Render Target and then copies a section of it to the target Render Target.

This method is extremely fast because it uses gl.copyTexSubImage2D and doesn't require the use of any shaders. Remember the coordinates are given in standard WebGL format, where x and y specify the lower-left corner of the section, not the top-left. Also, the copy entirely replaces the contents of the target texture, no 'merging' or 'blending' takes place.

Parameters:
Name Type Argument Default Description
source Phaser.Renderer.WebGL.RenderTarget

The source Render Target.

target Phaser.Renderer.WebGL.RenderTarget

The target Render Target.

x number

The x coordinate of the lower left corner where to start copying.

y number

The y coordinate of the lower left corner where to start copying.

width number

The width of the texture.

height number

The height of the texture.

clear boolean <optional>
true

Clear the target before copying?

clearAlpha boolean <optional>
true

Clear the alpha channel when running gl.clear on the target?

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 925)
Returns:

This Pipeline Manager instance.

Type
Phaser.Renderer.WebGL.PipelineManager

copyToGame(source)

Pops the framebuffer from the renderers FBO stack and sets that as the active target, then draws the source Render Target to it. It then resets the renderer textures.

This should be done when you need to draw the final results of a pipeline to the game canvas, or the next framebuffer in line on the FBO stack. You should only call this once in the onDraw handler and it should be the final thing called. Be careful not to call this if you need to actually use the pipeline shader, instead of the copy shader. In those cases, use the bindAndDraw method.

Parameters:
Name Type Description
source Phaser.Renderer.WebGL.RenderTarget

The Render Target to draw from.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 781)

destroy()

Destroy the Pipeline Manager, cleaning up all related resources and references.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 1092)

drawFrame(source [, target] [, clearAlpha] [, colorMatrix])

Copy the source Render Target to the target Render Target, using the given Color Matrix.

The difference between this method and copyFrame is that this method uses a color matrix shader, where you have full control over the luminance values used during the copy. If you don't need this, you can use the faster copyFrame method instead.

The copy itself is handled by the Utility Pipeline.

Parameters:
Name Type Argument Default Description
source Phaser.Renderer.WebGL.RenderTarget

The source Render Target.

target Phaser.Renderer.WebGL.RenderTarget <optional>

The target Render Target.

clearAlpha boolean <optional>
true

Clear the alpha channel when running gl.clear on the target?

colorMatrix Phaser.Display.ColorMatrix <optional>

The Color Matrix to use when performing the draw.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 803)
Returns:

This Pipeline Manager instance.

Type
Phaser.Renderer.WebGL.PipelineManager

flush()

Flushes the current pipeline, if one is bound.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 405)

forceZero()

Returns true if the current pipeline is forced to use texture unit zero.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 955)
Returns:

true if the current pipeline is forced to use texture unit zero.

Type
boolean

get(pipeline)

Returns the pipeline instance based on the given name, or instance.

If no instance, or matching name, exists in this manager, it returns undefined.

Parameters:
Name Type Description
pipeline string | Phaser.Renderer.WebGL.WebGLPipeline

Either the string-based name of the pipeline to get, or a pipeline instance to look-up.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 445)
Returns:

The pipeline instance, or undefined if not found.

Type
Phaser.Renderer.WebGL.WebGLPipeline

getPostPipeline(pipeline [, gameObject])

Returns a new instance of the post pipeline based on the given name, or class.

If no instance, or matching name, exists in this manager, it returns undefined.

Parameters:
Name Type Argument Description
pipeline string | function | Phaser.Renderer.WebGL.Pipelines.PostFXPipeline

Either the string-based name of the pipeline to get, or a pipeline instance, or class to look-up.

gameObject Phaser.GameObjects.GameObject <optional>

If this post pipeline is being installed into a Game Object or Camera, this is a reference to it.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 471)
Returns:

The pipeline instance, or undefined if not found.

Type
Phaser.Renderer.WebGL.Pipelines.PostFXPipeline

has(pipeline)

Checks if a pipeline is present in this Pipeline Manager.

Parameters:
Name Type Description
pipeline string | Phaser.Renderer.WebGL.WebGLPipeline

Either the string-based name of the pipeline to get, or a pipeline instance to look-up.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 419)
Returns:

true if the given pipeline is loaded, otherwise false.

Type
boolean

isCurrent(pipeline [, currentShader])

Checks to see if the given pipeline is already the active pipeline, both within this Pipeline Manager and also has the same shader set in the Renderer.

Parameters:
Name Type Argument Description
pipeline Phaser.Renderer.WebGL.WebGLPipeline

The pipeline instance to be checked.

currentShader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set as being current.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 727)
Returns:

true if the given pipeline is already the current pipeline, otherwise false.

Type
boolean

postBatch(gameObject)

This method is called by the WebGLPipeline.batchQuad method, right after a quad belonging to a Game Object has been added to the batch. It causes a batch flush, then calls the postBatch method on the post-fx pipelines belonging to the Game Object.

Parameters:
Name Type Description
gameObject Phaser.GameObjects.GameObject

The Game Object that was just added to the batch.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 633)

postBatchCamera(camera)

Called at the end of the WebGLRenderer.postRenderCamera method.

If the Camera has post pipelines set, it will flush the batch and then call the postBatch method on the post-fx pipelines belonging to the Camera.

Parameters:
Name Type Description
camera Phaser.Cameras.Scene2D.Camera

The Camera that was just rendered.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 696)

preBatch(gameObject)

This method is called by the WebGLPipeline.batchQuad method, right before a quad belonging to a Game Object is about to be added to the batch. It causes a batch flush, then calls the preBatch method on the post-fx pipelines belonging to the Game Object.

Parameters:
Name Type Description
gameObject Phaser.GameObjects.GameObject

The Game Object about to be batched.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 601)

preBatchCamera(camera)

Called at the start of the WebGLRenderer.preRenderCamera method.

If the Camera has post pipelines set, it will flush the batch and then call the preBatch method on the post-fx pipelines belonging to the Camera.

Parameters:
Name Type Description
camera Phaser.Cameras.Scene2D.Camera

The Camera about to be rendered.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 664)

rebind( [pipeline])

Use this to reset the gl context to the state that Phaser requires to continue rendering.

Calling this will:

  • Disable DEPTH_TEST, CULL_FACE and STENCIL_TEST.
  • Clear the depth buffer and stencil buffers.
  • Reset the viewport size.
  • Reset the blend mode.
  • Bind a blank texture as the active texture on texture unit zero.
  • Rebinds the given pipeline instance.

You should call this if you have previously called clear, and then wish to return rendering control to Phaser again.

Parameters:
Name Type Argument Description
pipeline Phaser.Renderer.WebGL.WebGLPipeline <optional>

The pipeline instance to be rebound. If not given, the previous pipeline will be bound.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 998)

remove(name [, removeClass] [, removePostPipelineClass])

Removes a pipeline instance based on the given name.

If no pipeline matches the name, this method does nothing.

Note that the pipeline will not be flushed or destroyed, it's simply removed from this manager.

Parameters:
Name Type Argument Default Description
name string

The name of the pipeline to be removed.

removeClass boolean <optional>
true

Remove the pipeline class as well as the instance?

removePostPipelineClass boolean <optional>
true

Remove the post pipeline class as well as the instance?

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 521)

set(pipeline [, gameObject] [, currentShader])

Sets the current pipeline to be used by the WebGLRenderer.

This method accepts a pipeline instance as its parameter, not the name.

If the pipeline isn't already the current one it will call WebGLPipeline.bind and then onBind.

You cannot set Post FX Pipelines using this method. To use a Post FX Pipeline, you should apply it to either a Camera, Container or other supporting Game Object.

Parameters:
Name Type Argument Description
pipeline Phaser.Renderer.WebGL.WebGLPipeline

The pipeline instance to be set as current.

gameObject Phaser.GameObjects.GameObject <optional>

The Game Object that invoked this pipeline, if any.

currentShader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set as being current.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 554)
Returns:

The pipeline that was set, or undefined if it couldn't be set.

Type
Phaser.Renderer.WebGL.WebGLPipeline

setMulti()

Sets the Multi Pipeline to be the currently bound pipeline.

This is the default Phaser 3 rendering pipeline.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 968)
Returns:

The Multi Pipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.MultiPipeline

setUtility( [currentShader])

Sets the Utility Pipeline to be the currently bound pipeline.

Parameters:
Name Type Argument Description
currentShader Phaser.Renderer.WebGL.WebGLShader <optional>

The shader to set as being current.

Since: 3.50.0
Source: src/renderer/webgl/PipelineManager.js (Line 983)
Returns:

The Utility Pipeline instance.

Type
Phaser.Renderer.WebGL.Pipelines.UtilityPipeline