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
bootmethod.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:
- Phaser.Structs.Map.<string, Class>
- 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
bootmethod.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
bootmethod.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
bootmethod.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
bootmethod.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
bootmethod.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
bootmethod.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:
- Phaser.Structs.Map.<string, Class>
- 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
clearPipelineis called and restored inrebindPipelineif 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
addPostPipelineinstead.Parameters:
Name Type Description namestring A unique string-based key for the pipeline within the manager.
pipelinePhaser.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.
-
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
addmethod instead.Parameters:
Name Type Description namestring A unique string-based key for the pipeline within the manager.
pipelinefunction A pipeline class which must extend
PostFXPipeline.- Since: 3.50.0
- Source: src/renderer/webgl/PipelineManager.js (Line 370)
Returns:
This Pipeline Manager.
-
blendFrames(source1, source2 [, target] [, strength] [, clearAlpha])
-
Draws the
source1andsource2Render Targets to thetargetRender Target using a linear blend effect, which is controlled by thestrengthparameter.The draw itself is handled by the Utility Pipeline.
Parameters:
Name Type Argument Default Description source1Phaser.Renderer.WebGL.RenderTarget The first source Render Target.
source2Phaser.Renderer.WebGL.RenderTarget The second source Render Target.
targetPhaser.Renderer.WebGL.RenderTarget <optional>
The target Render Target.
strengthnumber <optional>
1 The strength of the blend.
clearAlphaboolean <optional>
true Clear the alpha channel when running
gl.clearon the target?- Since: 3.50.0
- Source: src/renderer/webgl/PipelineManager.js (Line 831)
Returns:
This Pipeline Manager instance.
-
blendFramesAdditive(source1, source2 [, target] [, strength] [, clearAlpha])
-
Draws the
source1andsource2Render Targets to thetargetRender Target using an additive blend effect, which is controlled by thestrengthparameter.The draw itself is handled by the Utility Pipeline.
Parameters:
Name Type Argument Default Description source1Phaser.Renderer.WebGL.RenderTarget The first source Render Target.
source2Phaser.Renderer.WebGL.RenderTarget The second source Render Target.
targetPhaser.Renderer.WebGL.RenderTarget <optional>
The target Render Target.
strengthnumber <optional>
1 The strength of the blend.
clearAlphaboolean <optional>
true Clear the alpha channel when running
gl.clearon the target?- Since: 3.50.0
- Source: src/renderer/webgl/PipelineManager.js (Line 855)
Returns:
This Pipeline Manager instance.
-
blitFrame(source, target [, brightness] [, clear] [, clearAlpha] [, eraseMode])
-
Copy the
sourceRender Target to thetargetRender Target.The difference with this copy is that no resizing takes place. If the
sourceRender Target is larger than thetargetthen only a portion the same size as thetargetdimensions is copied across.You can optionally set the brightness factor of the copy.
Parameters:
Name Type Argument Default Description sourcePhaser.Renderer.WebGL.RenderTarget The source Render Target.
targetPhaser.Renderer.WebGL.RenderTarget The target Render Target.
brightnessnumber <optional>
1 The brightness value applied to the frame copy.
clearboolean <optional>
true Clear the target before copying?
clearAlphaboolean <optional>
true Clear the alpha channel when running
gl.clearon the target?eraseModeboolean <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.
-
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
bootmethod on each one of them.Finally, the default pipeline is set.
Parameters:
Name Type Argument Description pipelineConfigPhaser.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
rebindwhen 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 targetPhaser.Renderer.WebGL.RenderTarget The Render Target to clear.
clearAlphaboolean <optional>
true Clear the alpha channel when running
gl.clearon the target?- Since: 3.50.0
- Source: src/renderer/webgl/PipelineManager.js (Line 879)
Returns:
This Pipeline Manager instance.
-
copyFrame(source [, target] [, brightness] [, clear] [, clearAlpha])
-
Copy the
sourceRender Target to thetargetRender Target.You can optionally set the brightness factor of the copy.
The difference between this method and
drawFrameis that this method uses a faster copy shader, where only the brightness can be modified. If you need color level manipulation, seedrawFrameinstead.The copy itself is handled by the Utility Pipeline.
Parameters:
Name Type Argument Default Description sourcePhaser.Renderer.WebGL.RenderTarget The source Render Target.
targetPhaser.Renderer.WebGL.RenderTarget <optional>
The target Render Target.
brightnessnumber <optional>
1 The brightness value applied to the frame copy.
clearboolean <optional>
true Clear the target before copying?
clearAlphaboolean <optional>
true Clear the alpha channel when running
gl.clearon the target?- Since: 3.50.0
- Source: src/renderer/webgl/PipelineManager.js (Line 752)
Returns:
This Pipeline Manager instance.
-
copyFrameRect(source, target, x, y, width, height [, clear] [, clearAlpha])
-
Binds the
sourceRender Target and then copies a section of it to thetargetRender Target.This method is extremely fast because it uses
gl.copyTexSubImage2Dand 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 sourcePhaser.Renderer.WebGL.RenderTarget The source Render Target.
targetPhaser.Renderer.WebGL.RenderTarget The target Render Target.
xnumber The x coordinate of the lower left corner where to start copying.
ynumber The y coordinate of the lower left corner where to start copying.
widthnumber The width of the texture.
heightnumber The height of the texture.
clearboolean <optional>
true Clear the target before copying?
clearAlphaboolean <optional>
true Clear the alpha channel when running
gl.clearon the target?- Since: 3.50.0
- Source: src/renderer/webgl/PipelineManager.js (Line 925)
Returns:
This Pipeline Manager instance.
-
copyToGame(source)
-
Pops the framebuffer from the renderers FBO stack and sets that as the active target, then draws the
sourceRender 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
onDrawhandler 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 thebindAndDrawmethod.Parameters:
Name Type Description sourcePhaser.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
sourceRender Target to thetargetRender Target, using the given Color Matrix.The difference between this method and
copyFrameis 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 fastercopyFramemethod instead.The copy itself is handled by the Utility Pipeline.
Parameters:
Name Type Argument Default Description sourcePhaser.Renderer.WebGL.RenderTarget The source Render Target.
targetPhaser.Renderer.WebGL.RenderTarget <optional>
The target Render Target.
clearAlphaboolean <optional>
true Clear the alpha channel when running
gl.clearon the target?colorMatrixPhaser.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.
-
flush()
-
Flushes the current pipeline, if one is bound.
- Since: 3.50.0
- Source: src/renderer/webgl/PipelineManager.js (Line 405)
-
forceZero()
-
Returns
trueif the current pipeline is forced to use texture unit zero.- Since: 3.50.0
- Source: src/renderer/webgl/PipelineManager.js (Line 955)
Returns:
trueif 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 pipelinestring | 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
undefinedif not found. -
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 pipelinestring | 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.
gameObjectPhaser.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
undefinedif not found. -
has(pipeline)
-
Checks if a pipeline is present in this Pipeline Manager.
Parameters:
Name Type Description pipelinestring | 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:
trueif the given pipeline is loaded, otherwisefalse.- 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 pipelinePhaser.Renderer.WebGL.WebGLPipeline The pipeline instance to be checked.
currentShaderPhaser.Renderer.WebGL.WebGLShader <optional>
The shader to set as being current.
- Since: 3.50.0
- Source: src/renderer/webgl/PipelineManager.js (Line 727)
Returns:
trueif the given pipeline is already the current pipeline, otherwisefalse.- Type
- boolean
-
postBatch(gameObject)
-
This method is called by the
WebGLPipeline.batchQuadmethod, right after a quad belonging to a Game Object has been added to the batch. It causes a batch flush, then calls thepostBatchmethod on the post-fx pipelines belonging to the Game Object.Parameters:
Name Type Description gameObjectPhaser.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.postRenderCameramethod.If the Camera has post pipelines set, it will flush the batch and then call the
postBatchmethod on the post-fx pipelines belonging to the Camera.Parameters:
Name Type Description cameraPhaser.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.batchQuadmethod, right before a quad belonging to a Game Object is about to be added to the batch. It causes a batch flush, then calls thepreBatchmethod on the post-fx pipelines belonging to the Game Object.Parameters:
Name Type Description gameObjectPhaser.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.preRenderCameramethod.If the Camera has post pipelines set, it will flush the batch and then call the
preBatchmethod on the post-fx pipelines belonging to the Camera.Parameters:
Name Type Description cameraPhaser.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_FACEandSTENCIL_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 pipelinePhaser.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)
- Disable
-
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 namestring The name of the pipeline to be removed.
removeClassboolean <optional>
true Remove the pipeline class as well as the instance?
removePostPipelineClassboolean <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.bindand thenonBind.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 pipelinePhaser.Renderer.WebGL.WebGLPipeline The pipeline instance to be set as current.
gameObjectPhaser.GameObjects.GameObject <optional>
The Game Object that invoked this pipeline, if any.
currentShaderPhaser.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.
-
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.
-
setUtility( [currentShader])
-
Sets the Utility Pipeline to be the currently bound pipeline.
Parameters:
Name Type Argument Description currentShaderPhaser.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.
