The Light Pipeline is an extension of the Multi Pipeline and uses a custom shader designed to handle forward diffused rendering of 2D lights in a Scene.
The shader works in tandem with Light Game Objects, and optionally texture normal maps, to provide an ambient illumination effect.
If you wish to provide your own shader, you can use the %LIGHT_COUNT%
declaration in the source,
and it will be automatically replaced at run-time with the total number of configured lights.
The maximum number of lights can be set in the Render Config maxLights
property and defaults to 10.
Prior to Phaser v3.50 this pipeline was called the ForwardDiffuseLightPipeline
.
The fragment shader it uses can be found in shaders/src/Light.frag
.
The vertex shader it uses can be found in shaders/src/Multi.vert
.
The default shader attributes for this pipeline are:
inPosition
(vec2, offset 0)
inTexCoord
(vec2, offset 8)
inTexId
(float, offset 16)
inTintEffect
(float, offset 20)
inTint
(vec4, offset 24, normalized)
The default shader uniforms for this pipeline are those from the Multi Pipeline, plus:
uMainSampler
(sampler2D)
uNormSampler
(sampler2D)
uCamera
(vec4)
uResolution
(vec2)
uAmbientLightColor
(vec3)
uInverseRotationMatrix
(mat3)
uLights
(Light struct)
Constructor
new LightPipeline(config)
Parameters
name | type | optional | description |
---|---|---|---|
config | No | The configuration options for this pipeline. |
Scope: static
Extends
Source: src/renderer/webgl/pipelines/LightPipeline.js#L16
Since: 3.50.0
Public Members
active
active: boolean
Description:
Indicates if the current pipeline is active, or not.
Toggle this property to enable or disable a pipeline from rendering anything.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#active
Source: src/renderer/webgl/WebGLPipeline.js#L234
Since: 3.10.0
activeBuffer
activeBuffer: Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper
Description:
The currently active WebGLBuffer.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#activeBuffer
Source: src/renderer/webgl/WebGLPipeline.js#L187
Since: 3.60.0
activeTextures
activeTextures: Array.<Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper>
Description:
The currently active WebGLTextures, used as part of the batch process.
Reset to empty as part of the bind method.
Treat this array as read-only.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#activeTextures
Source: src/renderer/webgl/WebGLPipeline.js#L438
Since: 3.60.0
batch
batch: Array.<Phaser.Types.Renderer.WebGL.WebGLPipelineBatchEntry>
Description:
The temporary Pipeline batch. This array contains the batch entries for the current frame, which is a package of textures and vertex offsets used for drawing. This package is built dynamically as the frame is built and cleared during the flush method.
Treat this array and all of its contents as read-only.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#batch
Source: src/renderer/webgl/WebGLPipeline.js#L387
Since: 3.60.0
bytes
bytes: Uint8Array
Description:
Uint8 view to the vertexData
ArrayBuffer. Used for uploading vertex buffer resources to the GPU.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#bytes
Source: src/renderer/webgl/WebGLPipeline.js#L207
Since: 3.0.0
calcMatrix
calcMatrix: Phaser.GameObjects.Components.TransformMatrix
Description:
A temporary Transform Matrix, re-used internally during batching by the Shape Game Objects.
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#calcMatrix
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L184
Since: 3.55.0
config
config: Phaser.Types.Renderer.WebGL.WebGLPipelineConfig
Description:
The configuration object that was used to create this pipeline.
Treat this object as 'read only', because changing it post-creation will not impact this pipeline in any way. However, it is used internally for cloning and post-boot set-up.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#config
Source: src/renderer/webgl/WebGLPipeline.js#L361
Since: 3.50.0
currentBatch
currentBatch: Phaser.Types.Renderer.WebGL.WebGLPipelineBatchEntry
Description:
The most recently created Pipeline batch entry.
Reset to null as part of the flush method.
Treat this value as read-only.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#currentBatch
Source: src/renderer/webgl/WebGLPipeline.js#L401
Since: 3.60.0
currentNormalMap;
currentNormalMap;: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper
Description:
The currently bound normal map texture at texture unit one, if any.
Source: src/renderer/webgl/pipelines/LightPipeline.js#L88
Since: 3.60.0
currentRenderTarget
currentRenderTarget: Phaser.Renderer.WebGL.RenderTarget
Description:
A reference to the currently bound Render Target instance from the WebGLPipeline.renderTargets
array.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#currentRenderTarget
Source: src/renderer/webgl/WebGLPipeline.js#L298
Since: 3.50.0
currentShader
currentShader: Phaser.Renderer.WebGL.WebGLShader
Description:
A reference to the currently bound WebGLShader instance from the WebGLPipeline.shaders
array.
For lots of pipelines, this is the only shader, so it is a quick way to reference it without an array look-up.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#currentShader
Source: src/renderer/webgl/WebGLPipeline.js#L322
Since: 3.50.0
currentTexture
currentTexture: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper
Description:
The most recently bound texture, used as part of the batch process.
Reset to null as part of the flush method.
Treat this value as read-only.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#currentTexture
Source: src/renderer/webgl/WebGLPipeline.js#L414
Since: 3.60.0
currentUnit
currentUnit: number
Description:
Holds the most recently assigned texture unit.
Treat this value as read-only.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#currentUnit
Source: src/renderer/webgl/WebGLPipeline.js#L427
Since: 3.50.0
forceZero
forceZero: boolean
Description:
Some pipelines require the forced use of texture zero (like the light pipeline).
This property should be set when that is the case.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#forceZero
Source: src/renderer/webgl/WebGLPipeline.js#L245
Since: 3.50.0
game
game: Phaser.Game
Description:
The Phaser Game instance to which this pipeline is bound.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#game
Source: src/renderer/webgl/WebGLPipeline.js#L74
Since: 3.0.0
gl
gl: WebGLRenderingContext
Description:
The WebGL context this WebGL Pipeline uses.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#gl
Source: src/renderer/webgl/WebGLPipeline.js#L104
Since: 3.0.0
glReset
glReset: boolean
Description:
Has the GL Context been reset to the Phaser defaults since the last time this pipeline was bound? This is set automatically when the Pipeline Manager resets itself, usually after handing off to a 3rd party renderer like Spine.
You should treat this property as read-only.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#glReset
Source: src/renderer/webgl/WebGLPipeline.js#L374
Since: 3.53.0
hasBooted
hasBooted: boolean
Description:
Indicates if this pipeline has booted or not.
A pipeline boots only when the Game instance itself, and all associated systems, is fully ready.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#hasBooted
Source: src/renderer/webgl/WebGLPipeline.js#L256
Since: 3.50.0
height
height: number
Description:
Height of the current viewport.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#height
Source: src/renderer/webgl/WebGLPipeline.js#L131
Since: 3.0.0
isPostFX
isPostFX: boolean
Description:
Indicates if this is a Post FX Pipeline, or not.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#isPostFX
Source: src/renderer/webgl/WebGLPipeline.js#L269
Since: 3.50.0
isPreFX
isPreFX: boolean
Description:
Indicates if this is a Pre FX Pipeline, or not.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#isPreFX
Source: src/renderer/webgl/WebGLPipeline.js#L279
Since: 3.60.0
lightsActive
lightsActive: boolean
Description:
A boolean that is set automatically during onRender
that determines
if the Scene LightManager is active, or not.
Source: src/renderer/webgl/pipelines/LightPipeline.js#L97
Since: 3.53.0
manager
manager: Phaser.Renderer.WebGL.PipelineManager
Description:
A reference to the WebGL Pipeline Manager.
This is initially undefined and only set when this pipeline is added to the manager.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#manager
Source: src/renderer/webgl/WebGLPipeline.js#L92
Since: 3.50.0
name
name: string
Description:
Name of the pipeline. Used for identification and setting from Game Objects.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#name
Source: src/renderer/webgl/WebGLPipeline.js#L65
Since: 3.0.0
projectionHeight
projectionHeight: number
Description:
The cached height of the Projection matrix.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#projectionHeight
Source: src/renderer/webgl/WebGLPipeline.js#L352
Since: 3.50.0
projectionMatrix
projectionMatrix: Phaser.Math.Matrix4
Description:
The Projection matrix, used by shaders as 'uProjectionMatrix' uniform.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#projectionMatrix
Source: src/renderer/webgl/WebGLPipeline.js#L334
Since: 3.50.0
projectionWidth
projectionWidth: number
Description:
The cached width of the Projection matrix.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#projectionWidth
Source: src/renderer/webgl/WebGLPipeline.js#L343
Since: 3.50.0
renderer
renderer: Phaser.Renderer.WebGL.WebGLRenderer
Description:
The WebGL Renderer instance to which this pipeline is bound.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#renderer
Source: src/renderer/webgl/WebGLPipeline.js#L83
Since: 3.0.0
renderTargets
renderTargets: Array.<Phaser.Renderer.WebGL.RenderTarget>
Description:
An array of RenderTarget instances that belong to this pipeline.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#renderTargets
Source: src/renderer/webgl/WebGLPipeline.js#L289
Since: 3.50.0
resizeUniform
resizeUniform: string
Description:
If the WebGL Renderer changes size, this uniform will be set with the new width and height values
as part of the pipeline resize method. Various built-in pipelines, such as the MultiPipeline, set
this property automatically to uResolution
.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#resizeUniform
Source: src/renderer/webgl/WebGLPipeline.js#L451
Since: 3.80.0
shaders
shaders: Array.<Phaser.Renderer.WebGL.WebGLShader>
Description:
An array of all the WebGLShader instances that belong to this pipeline.
Shaders manage their own attributes and uniforms, but share the same vertex data buffer, which belongs to this pipeline.
Shaders are set in a call to the setShadersFromConfig
method, which happens automatically,
but can also be called at any point in your game. See the method documentation for details.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#shaders
Source: src/renderer/webgl/WebGLPipeline.js#L307
Since: 3.50.0
tempVec2
tempVec2: Phaser.Math.Vector2
Description:
A persistent calculation vector used when processing the lights.
Source: src/renderer/webgl/pipelines/LightPipeline.js#L108
Since: 3.60.0
topology
topology: GLenum
Description:
The primitive topology which the pipeline will use to submit draw calls.
Defaults to GL_TRIANGLES if not otherwise set in the config.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#topology
Source: src/renderer/webgl/WebGLPipeline.js#L196
Since: 3.0.0
vertexBuffer
vertexBuffer: Phaser.Renderer.WebGL.Wrappers.WebGLBufferWrapper
Description:
The WebGLBuffer that holds the vertex data.
Created from the vertexData
ArrayBuffer. If vertices
are set in the config, a STATIC_DRAW
buffer
is created. If not, a DYNAMIC_DRAW
buffer is created.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#vertexBuffer
Source: src/renderer/webgl/WebGLPipeline.js#L174
Since: 3.0.0
vertexCapacity
vertexCapacity: number
Description:
The total number of vertices that this pipeline batch can hold before it will flush.
This defaults to renderer batchSize * 6
, where batchSize
is defined in the Renderer Game Config.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#vertexCapacity
Source: src/renderer/webgl/WebGLPipeline.js#L150
Since: 3.0.0
vertexCount
vertexCount: number
Description:
The current number of vertices that have been added to the pipeline batch.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#vertexCount
Source: src/renderer/webgl/WebGLPipeline.js#L140
Since: 3.0.0
vertexData
vertexData: ArrayBuffer
Description:
Raw byte buffer of vertices.
Either set via the config object vertices
property, or generates a new Array Buffer of
size vertexCapacity * vertexSize
.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#vertexData
Source: src/renderer/webgl/WebGLPipeline.js#L161
Since: 3.0.0
vertexViewF32
vertexViewF32: Float32Array
Description:
Float32 view of the array buffer containing the pipeline's vertices.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#vertexViewF32
Source: src/renderer/webgl/WebGLPipeline.js#L216
Since: 3.0.0
vertexViewU32
vertexViewU32: Uint32Array
Description:
Uint32 view of the array buffer containing the pipeline's vertices.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#vertexViewU32
Source: src/renderer/webgl/WebGLPipeline.js#L225
Since: 3.0.0
view
view: HTMLCanvasElement
Description:
The canvas which this WebGL Pipeline renders to.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#view
Source: src/renderer/webgl/WebGLPipeline.js#L113
Since: 3.0.0
width
width: number
Description:
Width of the current viewport.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#width
Source: src/renderer/webgl/WebGLPipeline.js#L122
Since: 3.0.0
Private Members
_tempMatrix
_tempMatrix: Phaser.GameObjects.Components.TransformMatrix
Description:
A temporary Transform Matrix used for parent Container calculations without them needing their own local copy.
Access: private
Source: src/renderer/webgl/pipelines/LightPipeline.js#L117
Since: 3.60.0
_tempMatrix1
_tempMatrix1: Phaser.GameObjects.Components.TransformMatrix
Description:
A temporary Transform Matrix, re-used internally during batching.
Access: private
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#_tempMatrix1
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L154
Since: 3.11.0
_tempMatrix2
_tempMatrix2: Phaser.GameObjects.Components.TransformMatrix
Description:
A temporary Transform Matrix used for parent Container calculations without them needing their own local copy.
Access: private
Overrides: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#_tempMatrix2
Source: src/renderer/webgl/pipelines/LightPipeline.js#L127
Since: 3.60.0
_tempMatrix3
_tempMatrix3: Phaser.GameObjects.Components.TransformMatrix
Description:
A temporary Transform Matrix, re-used internally during batching.
Access: private
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#_tempMatrix3
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L174
Since: 3.11.0
currentFrame
currentFrame: Phaser.Textures.Frame
Description:
Internal texture frame reference.
Access: private
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#currentFrame
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L229
Since: 3.55.0
fillTint
fillTint: object
Description:
Cached fill tint.
Access: private
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#fillTint
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L219
Since: 3.55.0
firstQuad
firstQuad: Array.<number>
Description:
Internal path quad cache.
Access: private
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#firstQuad
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L239
Since: 3.55.0
inverseRotationMatrix
inverseRotationMatrix: Float32Array
Description:
Inverse rotation matrix for normal map rotations.
Access: private
Source: src/renderer/webgl/pipelines/LightPipeline.js#L74
Since: 3.16.0
polygonCache
polygonCache: array
Description:
Used internally for triangulating a polygon.
Access: private
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#polygonCache
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L259
Since: 3.55.0
prevQuad
prevQuad: Array.<number>
Description:
Internal path quad cache.
Access: private
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#prevQuad
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L249
Since: 3.55.0
strokeTint
strokeTint: object
Description:
Cached stroke tint.
Access: private
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#strokeTint
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L209
Since: 3.55.0
tempTriangle
tempTriangle: array
Description:
Used internally to draw stroked triangles.
Access: private
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#tempTriangle
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L194
Since: 3.55.0
Public Methods
addListener
<instance> addListener(event, fn, [context])
Description:
Add a listener for a given event.
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
event | string | symbol | No | The event name. | |
fn | function | No | The listener function. | |
context | * | Yes | "this" | The context to invoke the listener with. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - this
.
Inherits: Phaser.Events.EventEmitter#addListener
Source: src/events/EventEmitter.js#L111
Since: 3.0.0
addTextureToBatch
<instance> addTextureToBatch(texture)
Description:
Adds the given texture to the current WebGL Pipeline Batch Entry and increases the batch entry unit and maxUnit values by 1.
Parameters:
name | type | optional | description |
---|---|---|---|
texture | No | The texture assigned to this batch entry. |
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#addTextureToBatch
Source: src/renderer/webgl/WebGLPipeline.js#L818
Since: 3.60.0
batchFillPath
<instance> batchFillPath(path, currentMatrix, parentMatrix)
Description:
Adds the given path to the vertex batch for rendering.
It works by taking the array of path data and then passing it through Earcut, which creates a list of polygons. Each polygon is then added to the batch.
The path is always automatically closed because it's filled.
Parameters:
name | type | optional | description |
---|---|---|---|
path | Array.<Phaser.Types.Math.Vector2Like> | No | Collection of points that represent the path. |
currentMatrix | No | The current transform. | |
parentMatrix | No | The parent transform. |
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchFillPath
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L772
Since: 3.55.0
batchFillRect
<instance> batchFillRect(x, y, width, height, currentMatrix, parentMatrix)
Description:
Pushes a filled rectangle into the vertex batch.
Rectangle factors in the given transform matrices before adding to the batch.
Parameters:
name | type | optional | description |
---|---|---|---|
x | number | No | Horizontal top left coordinate of the rectangle. |
y | number | No | Vertical top left coordinate of the rectangle. |
width | number | No | Width of the rectangle. |
height | number | No | Height of the rectangle. |
currentMatrix | No | The current transform. | |
parentMatrix | No | The parent transform. |
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchFillRect
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L652
Since: 3.55.0
batchFillTriangle
<instance> batchFillTriangle(x0, y0, x1, y1, x2, y2, currentMatrix, parentMatrix)
Description:
Pushes a filled triangle into the vertex batch.
Triangle factors in the given transform matrices before adding to the batch.
Parameters:
name | type | optional | description |
---|---|---|---|
x0 | number | No | Point 0 x coordinate. |
y0 | number | No | Point 0 y coordinate. |
x1 | number | No | Point 1 x coordinate. |
y1 | number | No | Point 1 y coordinate. |
x2 | number | No | Point 2 x coordinate. |
y2 | number | No | Point 2 y coordinate. |
currentMatrix | No | The current transform. | |
parentMatrix | No | The parent transform. |
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchFillTriangle
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L686
Since: 3.55.0
batchLine
<instance> batchLine(ax, ay, bx, by, aLineWidth, bLineWidth, index, closePath, currentMatrix, parentMatrix)
Description:
Creates a line out of 4 quads and adds it to the vertex batch based on the given line values.
Parameters:
name | type | optional | description |
---|---|---|---|
ax | number | No | x coordinate of the start of the line. |
ay | number | No | y coordinate of the start of the line. |
bx | number | No | x coordinate of the end of the line. |
by | number | No | y coordinate of the end of the line. |
aLineWidth | number | No | Width of the start of the line. |
bLineWidth | number | No | Width of the end of the line. |
index | number | No | If this line is part of a multi-line draw, the index of the line in the draw. |
closePath | boolean | No | Does this line close a multi-line path? |
currentMatrix | No | The current transform. | |
parentMatrix | No | The parent transform. |
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchLine
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L893
Since: 3.55.0
batchQuad
<instance> batchQuad(gameObject, x0, y0, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintBR, tintEffect, [texture], [unit])
Description:
Adds the vertices data into the batch and flushes if full.
Assumes 6 vertices in the following arrangement:
0----3
|\ B|
| \ |
| \ |
| A \|
| \
1----2
Where tx0/ty0 = 0, tx1/ty1 = 1, tx2/ty2 = 2 and tx3/ty3 = 3
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
gameObject | No | The Game Object, if any, drawing this quad. | ||
x0 | number | No | The top-left x position. | |
y0 | number | No | The top-left y position. | |
x1 | number | No | The bottom-left x position. | |
y1 | number | No | The bottom-left y position. | |
x2 | number | No | The bottom-right x position. | |
y2 | number | No | The bottom-right y position. | |
x3 | number | No | The top-right x position. | |
y3 | number | No | The top-right y position. | |
u0 | number | No | UV u0 value. | |
v0 | number | No | UV v0 value. | |
u1 | number | No | UV u1 value. | |
v1 | number | No | UV v1 value. | |
tintTL | number | No | The top-left tint color value. | |
tintTR | number | No | The top-right tint color value. | |
tintBL | number | No | The bottom-left tint color value. | |
tintBR | number | No | The bottom-right tint color value. | |
tintEffect | number | boolean | No | The tint effect for the shader to use. | |
texture | Yes | Texture that will be assigned to the current batch if a flush occurs. | ||
unit | number | Yes | 0 | Texture unit to which the texture needs to be bound. |
Returns: boolean - true
if this method caused the batch to flush, otherwise false
.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#batchQuad
Source: src/renderer/webgl/WebGLPipeline.js#L1704
Since: 3.50.0
batchSprite
<instance> batchSprite(gameObject, camera, [parentTransformMatrix])
Description:
Takes a Sprite Game Object, or any object that extends it, and adds it to the batch.
Parameters:
name | type | optional | description |
---|---|---|---|
gameObject | No | The texture based Game Object to add to the batch. | |
camera | No | The Camera to use for the rendering transform. | |
parentTransformMatrix | Yes | The transform matrix of the parent container, if set. |
Overrides: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchSprite
Source: src/renderer/webgl/pipelines/LightPipeline.js#L422
Since: 3.50.0
batchStrokePath
<instance> batchStrokePath(path, lineWidth, pathOpen, currentMatrix, parentMatrix)
Description:
Adds the given path to the vertex batch for rendering.
It works by taking the array of path data and calling batchLine
for each section
of the path.
The path is optionally closed at the end.
Parameters:
name | type | optional | description |
---|---|---|---|
path | Array.<Phaser.Types.Math.Vector2Like> | No | Collection of points that represent the path. |
lineWidth | number | No | The width of the line segments in pixels. |
pathOpen | boolean | No | Indicates if the path should be closed or left open. |
currentMatrix | No | The current transform. | |
parentMatrix | No | The parent transform. |
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchStrokePath
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L845
Since: 3.55.0
batchStrokeTriangle
<instance> batchStrokeTriangle(x0, y0, x1, y1, x2, y2, lineWidth, currentMatrix, parentMatrix)
Description:
Pushes a stroked triangle into the vertex batch.
Triangle factors in the given transform matrices before adding to the batch.
The triangle is created from 3 lines and drawn using the batchStrokePath
method.
Parameters:
name | type | optional | description |
---|---|---|---|
x0 | number | No | Point 0 x coordinate. |
y0 | number | No | Point 0 y coordinate. |
x1 | number | No | Point 1 x coordinate. |
y1 | number | No | Point 1 y coordinate. |
x2 | number | No | Point 2 x coordinate. |
y2 | number | No | Point 2 y coordinate. |
lineWidth | number | No | The width of the line in pixels. |
currentMatrix | No | The current transform. | |
parentMatrix | No | The parent transform. |
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchStrokeTriangle
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L729
Since: 3.55.0
batchTexture
<instance> batchTexture(gameObject, texture, textureWidth, textureHeight, srcX, srcY, srcWidth, srcHeight, scaleX, scaleY, rotation, flipX, flipY, scrollFactorX, scrollFactorY, displayOriginX, displayOriginY, frameX, frameY, frameWidth, frameHeight, tintTL, tintTR, tintBL, tintBR, tintEffect, uOffset, vOffset, camera, parentTransformMatrix, [skipFlip], [textureUnit])
Description:
Generic function for batching a textured quad using argument values instead of a Game Object.
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
gameObject | No | Source GameObject. | ||
texture | No | Texture associated with the quad. | ||
textureWidth | number | No | Real texture width. | |
textureHeight | number | No | Real texture height. | |
srcX | number | No | X coordinate of the quad. | |
srcY | number | No | Y coordinate of the quad. | |
srcWidth | number | No | Width of the quad. | |
srcHeight | number | No | Height of the quad. | |
scaleX | number | No | X component of scale. | |
scaleY | number | No | Y component of scale. | |
rotation | number | No | Rotation of the quad. | |
flipX | boolean | No | Indicates if the quad is horizontally flipped. | |
flipY | boolean | No | Indicates if the quad is vertically flipped. | |
scrollFactorX | number | No | By which factor is the quad affected by the camera horizontal scroll. | |
scrollFactorY | number | No | By which factor is the quad effected by the camera vertical scroll. | |
displayOriginX | number | No | Horizontal origin in pixels. | |
displayOriginY | number | No | Vertical origin in pixels. | |
frameX | number | No | X coordinate of the texture frame. | |
frameY | number | No | Y coordinate of the texture frame. | |
frameWidth | number | No | Width of the texture frame. | |
frameHeight | number | No | Height of the texture frame. | |
tintTL | number | No | Tint for top left. | |
tintTR | number | No | Tint for top right. | |
tintBL | number | No | Tint for bottom left. | |
tintBR | number | No | Tint for bottom right. | |
tintEffect | number | No | The tint effect. | |
uOffset | number | No | Horizontal offset on texture coordinate. | |
vOffset | number | No | Vertical offset on texture coordinate. | |
camera | No | Current used camera. | ||
parentTransformMatrix | No | Parent container. | ||
skipFlip | boolean | Yes | false | Skip the renderTexture check. |
textureUnit | number | Yes | Use the currently bound texture unit? |
Overrides: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchTexture
Source: src/renderer/webgl/pipelines/LightPipeline.js#L440
Since: 3.50.0
batchTextureFrame
<instance> batchTextureFrame(frame, x, y, tint, alpha, transformMatrix, [parentTransformMatrix])
Description:
Adds a Texture Frame into the batch for rendering.
Parameters:
name | type | optional | description |
---|---|---|---|
frame | No | The Texture Frame to be rendered. | |
x | number | No | The horizontal position to render the texture at. |
y | number | No | The vertical position to render the texture at. |
tint | number | No | The tint color. |
alpha | number | No | The alpha value. |
transformMatrix | No | The Transform Matrix to use for the texture. | |
parentTransformMatrix | Yes | A parent Transform Matrix. |
Overrides: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchTextureFrame
Source: src/renderer/webgl/pipelines/LightPipeline.js#L523
Since: 3.50.0
batchTri
<instance> batchTri(gameObject, x1, y1, x2, y2, x3, y3, u0, v0, u1, v1, tintTL, tintTR, tintBL, tintEffect, [texture], [unit])
Description:
Adds the vertices data into the batch and flushes if full.
Assumes 3 vertices in the following arrangement:
0
|\
| \
| \
| \
| \
1-----2
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
gameObject | No | The Game Object, if any, drawing this quad. | ||
x1 | number | No | The bottom-left x position. | |
y1 | number | No | The bottom-left y position. | |
x2 | number | No | The bottom-right x position. | |
y2 | number | No | The bottom-right y position. | |
x3 | number | No | The top-right x position. | |
y3 | number | No | The top-right y position. | |
u0 | number | No | UV u0 value. | |
v0 | number | No | UV v0 value. | |
u1 | number | No | UV u1 value. | |
v1 | number | No | UV v1 value. | |
tintTL | number | No | The top-left tint color value. | |
tintTR | number | No | The top-right tint color value. | |
tintBL | number | No | The bottom-left tint color value. | |
tintEffect | number | boolean | No | The tint effect for the shader to use. | |
texture | Yes | Texture that will be assigned to the current batch if a flush occurs. | ||
unit | number | Yes | 0 | Texture unit to which the texture needs to be bound. |
Returns: boolean - true
if this method caused the batch to flush, otherwise false
.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#batchTri
Source: src/renderer/webgl/WebGLPipeline.js#L1827
Since: 3.50.0
batchVert
<instance> batchVert(x, y, u, v, unit, tintEffect, tint)
Description:
Adds a single vertex to the current vertex buffer and increments the
vertexCount
property by 1.
This method is called directly by batchTri
and batchQuad
.
It does not perform any batch limit checking itself, so if you need to call
this method directly, do so in the same way that batchQuad
does, for example.
Parameters:
name | type | optional | description |
---|---|---|---|
x | number | No | The vertex x position. |
y | number | No | The vertex y position. |
u | number | No | UV u value. |
v | number | No | UV v value. |
unit | number | No | Texture unit to which the texture needs to be bound. |
tintEffect | number | boolean | No | The tint effect for the shader to use. |
tint | number | No | The tint color value. |
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#batchVert
Source: src/renderer/webgl/WebGLPipeline.js#L1664
Since: 3.50.0
bind
<instance> bind([currentShader])
Description:
This method is called every time the Pipeline Manager makes this pipeline the currently active one.
It binds the resources and shader needed for this pipeline, including setting the vertex buffer and attribute pointers.
Parameters:
name | type | optional | description |
---|---|---|---|
currentShader | Yes | The shader to set as being current. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Fires: Phaser.Renderer.WebGL.Pipelines.Events#event:BIND
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#bind
Source: src/renderer/webgl/WebGLPipeline.js#L1120
Since: 3.0.0
bindRenderTarget
<instance> bindRenderTarget([target], [unit])
Description:
Activates the given Render Target texture and binds it to the requested WebGL texture slot.
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
target | Yes | The Render Target to activate and bind. | ||
unit | number | Yes | 0 | The WebGL texture ID to activate. Defaults to |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGL Pipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#bindRenderTarget
Source: src/renderer/webgl/WebGLPipeline.js#L2013
Since: 3.50.0
bindTexture
<instance> bindTexture([target], [unit])
Description:
Activates the given WebGL Texture and binds it to the requested texture slot.
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
target | Yes | Texture to activate and bind. | ||
unit | number | Yes | 0 | The WebGL texture ID to activate. Defaults to |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGL Pipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#bindTexture
Source: src/renderer/webgl/WebGLPipeline.js#L1989
Since: 3.50.0
boot
<instance> boot()
Description:
Called when the Game has fully booted and the Renderer has finished setting up.
By this stage all Game level systems are now in place and you can perform any final tasks that the pipeline may need that relied on game systems such as the Texture Manager.
Overrides: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#boot
Source: src/renderer/webgl/pipelines/LightPipeline.js#L138
Since: 3.11.0
createBatch
<instance> createBatch(texture)
Description:
Creates a new WebGL Pipeline Batch Entry, sets the texture unit as zero and pushes the entry into the batch.
Parameters:
name | type | optional | description |
---|---|---|---|
texture | No | The texture assigned to this batch entry. |
Returns: number - The texture unit that was bound.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#createBatch
Source: src/renderer/webgl/WebGLPipeline.js#L789
Since: 3.60.0
destroy
<instance> destroy()
Description:
Destroys all shader instances, removes all object references and nulls all external references.
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Fires: Phaser.Renderer.WebGL.Pipelines.Events#event:DESTROY
Inherits: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#destroy
Source: src/renderer/webgl/pipelines/MultiPipeline.js#L1012
Since: 3.60.0
drawFillRect
<instance> drawFillRect(x, y, width, height, color, alpha, [texture], [flipUV])
Description:
Pushes a filled rectangle into the vertex batch.
The dimensions are run through Math.floor
before the quad is generated.
Rectangle has no transform values and isn't transformed into the local space.
Used for directly batching untransformed rectangles, such as Camera background colors.
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
x | number | No | Horizontal top left coordinate of the rectangle. | |
y | number | No | Vertical top left coordinate of the rectangle. | |
width | number | No | Width of the rectangle. | |
height | number | No | Height of the rectangle. | |
color | number | No | Color of the rectangle to draw. | |
alpha | number | No | Alpha value of the rectangle to draw. | |
texture | Yes | texture that will be assigned to the current batch if a flush occurs. | ||
flipUV | boolean | Yes | true | Flip the vertical UV coordinates of the texture before rendering? |
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#drawFillRect
Source: src/renderer/webgl/WebGLPipeline.js#L1921
Since: 3.50.0
emit
<instance> emit(event, [args])
Description:
Calls each of the listeners registered for a given event.
Parameters:
name | type | optional | description |
---|---|---|---|
event | string | symbol | No | The event name. |
args | * | Yes | Additional arguments that will be passed to the event handler. |
Returns: boolean - true
if the event had listeners, else false
.
Inherits: Phaser.Events.EventEmitter#emit
Source: src/events/EventEmitter.js#L86
Since: 3.0.0
eventNames
<instance> eventNames()
Description:
Return an array listing the events for which the emitter has registered listeners.
Returns: Array.<(string | symbol)> - undefined
Inherits: Phaser.Events.EventEmitter#eventNames
Source: src/events/EventEmitter.js#L55
Since: 3.0.0
flipProjectionMatrix
<instance> flipProjectionMatrix([flipY])
Description:
Adjusts this pipelines ortho Projection Matrix to flip the y and bottom values. Call with 'false' as the parameter to flip them back again.
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
flipY | boolean | Yes | true | Flip the y and bottom values? |
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#flipProjectionMatrix
Source: src/renderer/webgl/WebGLPipeline.js#L1059
Since: 3.60.0
flush
<instance> flush([isPostFlush])
Description:
Uploads the vertex data and emits a draw call for the current batch of vertices.
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
isPostFlush | boolean | Yes | false | Was this flush invoked as part of a post-process, or not? |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Fires: Phaser.Renderer.WebGL.Pipelines.Events#event:BEFORE_FLUSH, Phaser.Renderer.WebGL.Pipelines.Events#event:AFTER_FLUSH
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#flush
Source: src/renderer/webgl/WebGLPipeline.js#L1370
Since: 3.0.0
getNormalMap
<instance> getNormalMap([gameObject])
Description:
Returns the normal map WebGLTextureWrapper from the given Game Object. If the Game Object doesn't have one, it returns the default normal map from this pipeline instead.
Parameters:
name | type | optional | description |
---|---|---|---|
gameObject | Yes | The Game Object to get the normal map from. |
Returns: Phaser.Renderer.WebGL.Wrappers.WebGLTextureWrapper - The normal map texture.
Source: src/renderer/webgl/pipelines/LightPipeline.js#L375
Since: 3.50.0
getShaderByName
<instance> getShaderByName(name)
Description:
Searches all shaders in this pipeline for one matching the given name, then returns it.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The index of the shader to set. |
Returns: Phaser.Renderer.WebGL.WebGLShader - The WebGLShader instance, if found.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#getShaderByName
Source: src/renderer/webgl/WebGLPipeline.js#L662
Since: 3.50.0
listenerCount
<instance> listenerCount(event)
Description:
Return the number of listeners listening to a given event.
Parameters:
name | type | optional | description |
---|---|---|---|
event | string | symbol | No | The event name. |
Returns: number - The number of listeners.
Inherits: Phaser.Events.EventEmitter#listenerCount
Source: src/events/EventEmitter.js#L75
Since: 3.0.0
listeners
<instance> listeners(event)
Description:
Return the listeners registered for a given event.
Parameters:
name | type | optional | description |
---|---|---|---|
event | string | symbol | No | The event name. |
Returns: Array.<function()> - The registered listeners.
Inherits: Phaser.Events.EventEmitter#listeners
Source: src/events/EventEmitter.js#L64
Since: 3.0.0
off
<instance> off(event, [fn], [context], [once])
Description:
Remove the listeners of a given event.
Parameters:
name | type | optional | description |
---|---|---|---|
event | string | symbol | No | The event name. |
fn | function | Yes | Only remove the listeners that match this function. |
context | * | Yes | Only remove the listeners that have this context. |
once | boolean | Yes | Only remove one-time listeners. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - this
.
Inherits: Phaser.Events.EventEmitter#off
Source: src/events/EventEmitter.js#L151
Since: 3.0.0
on
<instance> on(event, fn, [context])
Description:
Add a listener for a given event.
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
event | string | symbol | No | The event name. | |
fn | function | No | The listener function. | |
context | * | Yes | "this" | The context to invoke the listener with. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - this
.
Inherits: Phaser.Events.EventEmitter#on
Source: src/events/EventEmitter.js#L98
Since: 3.0.0
onActive
<instance> onActive(currentShader)
Description:
By default this is an empty method hook that you can override and use in your own custom pipelines.
This method is called every time the Pipeline Manager makes this the active pipeline. It is called
at the end of the WebGLPipeline.bind
method, after the current shader has been set. The current
shader is passed to this hook.
For example, if a display list has 3 Sprites in it that all use the same pipeline, this hook will only be called for the first one, as the 2nd and 3rd Sprites do not cause the pipeline to be changed.
If you need to listen for that event instead, use the onBind
hook.
Parameters:
name | type | optional | description |
---|---|---|---|
currentShader | No | The shader that was set as current. |
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#onActive
Source: src/renderer/webgl/WebGLPipeline.js#L1478
Since: 3.50.0
onAfterFlush
<instance> onAfterFlush([isPostFlush])
Description:
By default this is an empty method hook that you can override and use in your own custom pipelines.
This method is called immediately after this pipeline has finished flushing its batch.
It is called after the gl.drawArrays
call.
You can perform additional post-render effects, but be careful not to call flush
on this pipeline from within this method, or you'll cause an infinite loop.
To apply changes pre-render, see onBeforeFlush
.
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
isPostFlush | boolean | Yes | false | Was this flush invoked as part of a post-process, or not? |
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#onAfterFlush
Source: src/renderer/webgl/WebGLPipeline.js#L1643
Since: 3.50.0
onBatch
<instance> onBatch([gameObject])
Description:
By default this is an empty method hook that you can override and use in your own custom pipelines.
This method is called every time the batchQuad
or batchTri
methods are called. If this was
as a result of a Game Object, then the Game Object reference is passed to this hook too.
This hook is called after the quad (or tri) has been added to the batch, so you can safely call 'flush' from within this.
Note that Game Objects may call batchQuad
or batchTri
multiple times for a single draw,
for example the Graphics Game Object.
Parameters:
name | type | optional | description |
---|---|---|---|
gameObject | Yes | The Game Object that invoked this pipeline, if any. |
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#onBatch
Source: src/renderer/webgl/WebGLPipeline.js#L1532
Since: 3.50.0
onBeforeFlush
<instance> onBeforeFlush([isPostFlush])
Description:
By default this is an empty method hook that you can override and use in your own custom pipelines.
This method is called every time this pipeline is asked to flush its batch.
It is called immediately before the gl.bufferData
and gl.drawArrays
calls are made, so you can
perform any final pre-render modifications. To apply changes post-render, see onAfterFlush
.
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
isPostFlush | boolean | Yes | false | Was this flush invoked as part of a post-process, or not? |
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#onBeforeFlush
Source: src/renderer/webgl/WebGLPipeline.js#L1626
Since: 3.50.0
onBind
<instance> onBind([gameObject])
Description:
By default this is an empty method hook that you can override and use in your own custom pipelines.
This method is called every time a Game Object asks the Pipeline Manager to use this pipeline, even if the pipeline is already active.
Unlike the onActive
method, which is only called when the Pipeline Manager makes this pipeline
active, this hook is called for every Game Object that requests use of this pipeline, allowing you to
perform per-object set-up, such as loading shader uniform data.
Parameters:
name | type | optional | description |
---|---|---|---|
gameObject | Yes | The Game Object that invoked this pipeline, if any. |
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#onBind
Source: src/renderer/webgl/WebGLPipeline.js#L1499
Since: 3.50.0
onBoot
<instance> onBoot()
Description:
This method is called once when this pipeline has finished being set-up at the end of the boot process. By the time this method is called, all of the shaders are ready and configured.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#onBoot
Source: src/renderer/webgl/WebGLPipeline.js#L599
Since: 3.50.0
once
<instance> once(event, fn, [context])
Description:
Add a one-time listener for a given event.
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
event | string | symbol | No | The event name. | |
fn | function | No | The listener function. | |
context | * | Yes | "this" | The context to invoke the listener with. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - this
.
Inherits: Phaser.Events.EventEmitter#once
Source: src/events/EventEmitter.js#L124
Since: 3.0.0
onDraw
<instance> onDraw(renderTarget, [swapTarget])
Description:
This method is only used by Sprite FX and Post FX Pipelines and those that extend from them.
This method is called every time the postBatch
method is called and is passed a
reference to the current render target.
At the very least a Post FX Pipeline should call this.bindAndDraw(renderTarget)
,
however, you can do as much additional processing as you like in this method if
you override it from within your own pipelines.
Parameters:
name | type | optional | description |
---|---|---|---|
renderTarget | No | The Render Target. | |
swapTarget | Yes | A Swap Render Target, useful for double-buffer effects. Only set by SpriteFX Pipelines. |
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#onDraw
Source: src/renderer/webgl/WebGLPipeline.js#L1335
Since: 3.50.0
onPostBatch
<instance> onPostBatch([gameObject])
Description:
By default this is an empty method hook that you can override and use in your own custom pipelines.
This method is called immediately after a Game Object has been added to the batch.
Parameters:
name | type | optional | description |
---|---|---|---|
gameObject | Yes | The Game Object that invoked this pipeline, if any. |
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#onPostBatch
Source: src/renderer/webgl/WebGLPipeline.js#L1567
Since: 3.50.0
onPostRender
<instance> onPostRender()
Description:
By default this is an empty method hook that you can override and use in your own custom pipelines.
This method is called once per frame, after all rendering has happened and snapshots have been taken.
It is called at the very end of the rendering process, once all Cameras, for all Scenes, have been rendered.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#onPostRender
Source: src/renderer/webgl/WebGLPipeline.js#L1611
Since: 3.50.0
onPreBatch
<instance> onPreBatch([gameObject])
Description:
By default this is an empty method hook that you can override and use in your own custom pipelines.
This method is called immediately before a Game Object is about to add itself to the batch.
Parameters:
name | type | optional | description |
---|---|---|---|
gameObject | Yes | The Game Object that invoked this pipeline, if any. |
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#onPreBatch
Source: src/renderer/webgl/WebGLPipeline.js#L1553
Since: 3.50.0
onPreRender
<instance> onPreRender()
Description:
By default this is an empty method hook that you can override and use in your own custom pipelines.
This method is called once per frame, right before anything has been rendered, but after the canvas has been cleared. If this pipeline has a render target, it will also have been cleared by this point.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#onPreRender
Source: src/renderer/webgl/WebGLPipeline.js#L1581
Since: 3.50.0
onRebind
<instance> onRebind()
Description:
By default this is an empty method hook that you can override and use in your own custom pipelines.
This method is called when the Pipeline Manager needs to rebind this pipeline. This happens after a pipeline has been cleared, usually when passing control over to a 3rd party WebGL library, like Spine, and then returing to Phaser again.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#onRebind
Source: src/renderer/webgl/WebGLPipeline.js#L1518
Since: 3.50.0
onRender
<instance> onRender(scene, camera)
Description:
This function sets all the needed resources for each camera pass.
Parameters:
name | type | optional | description |
---|---|---|---|
scene | No | The Scene being rendered. | |
camera | No | The Scene Camera being rendered with. |
Overrides: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#onRender
Source: src/renderer/webgl/pipelines/LightPipeline.js#L152
Since: 3.0.0
onResize
<instance> onResize(width, height)
Description:
This method is called once when this pipeline has finished being set-up at the end of the boot process. By the time this method is called, all of the shaders are ready and configured. It's also called if the renderer changes size.
Parameters:
name | type | optional | description |
---|---|---|---|
width | number | No | The new width of this WebGL Pipeline. |
height | number | No | The new height of this WebGL Pipeline. |
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#onResize
Source: src/renderer/webgl/WebGLPipeline.js#L611
Since: 3.50.0
postBatch
<instance> postBatch([gameObject])
Description:
This method is called as a result of the WebGLPipeline.batchQuad
method, right after a quad
belonging to a Game Object has been added to the batch. When this is called, the
renderer has just performed a flush.
It calls the onDraw
hook followed by the onPostBatch
hook, which can be used to perform
additional Post FX Pipeline processing.
It is also called as part of the PipelineManager.postBatch
method when processing Post FX Pipelines.
Parameters:
name | type | optional | description |
---|---|---|---|
gameObject | Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera | Yes | The Game Object or Camera that invoked this pipeline, if any. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#postBatch
Source: src/renderer/webgl/WebGLPipeline.js#L1309
Since: 3.50.0
preBatch
<instance> preBatch([gameObject])
Description:
This method is called as a result of the WebGLPipeline.batchQuad
method, right before a quad
belonging to a Game Object is about to be added to the batch. When this is called, the
renderer has just performed a flush. It will bind the current render target, if any are set
and finally call the onPreBatch
hook.
It is also called as part of the PipelineManager.preBatch
method when processing Post FX Pipelines.
Parameters:
name | type | optional | description |
---|---|---|---|
gameObject | Phaser.GameObjects.GameObject | Phaser.Cameras.Scene2D.Camera | Yes | The Game Object or Camera that invoked this pipeline, if any. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#preBatch
Source: src/renderer/webgl/WebGLPipeline.js#L1282
Since: 3.50.0
pushBatch
<instance> pushBatch(texture)
Description:
Takes the given WebGLTextureWrapper and determines what to do with it.
If there is no current batch (i.e. after a flush) it will create a new batch from it.
If the texture is already bound, it will return the current texture unit.
If the texture already exists in the current batch, the unit gets reset to match it.
If the texture cannot be found in the current batch, and it supports multiple textures, it's added into the batch and the unit indexes are advanced.
Parameters:
name | type | optional | description |
---|---|---|---|
texture | No | The texture assigned to this batch entry. |
Returns: number - The texture unit that was bound.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#pushBatch
Source: src/renderer/webgl/WebGLPipeline.js#L839
Since: 3.60.0
rebind
<instance> rebind([currentShader])
Description:
This method is called every time the Pipeline Manager rebinds this pipeline.
It resets all shaders this pipeline uses, setting their attributes again.
Parameters:
name | type | optional | description |
---|---|---|---|
currentShader | Yes | The shader to set as being current. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Fires: Phaser.Renderer.WebGL.Pipelines.Events#event:REBIND
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#rebind
Source: src/renderer/webgl/WebGLPipeline.js#L1169
Since: 3.0.0
removeAllListeners
<instance> removeAllListeners([event])
Description:
Remove all listeners, or those of the specified event.
Parameters:
name | type | optional | description |
---|---|---|---|
event | string | symbol | Yes | The event name. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - this
.
Inherits: Phaser.Events.EventEmitter#removeAllListeners
Source: src/events/EventEmitter.js#L165
Since: 3.0.0
removeListener
<instance> removeListener(event, [fn], [context], [once])
Description:
Remove the listeners of a given event.
Parameters:
name | type | optional | description |
---|---|---|---|
event | string | symbol | No | The event name. |
fn | function | Yes | Only remove the listeners that match this function. |
context | * | Yes | Only remove the listeners that have this context. |
once | boolean | Yes | Only remove one-time listeners. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - this
.
Inherits: Phaser.Events.EventEmitter#removeListener
Source: src/events/EventEmitter.js#L137
Since: 3.0.0
resize
<instance> resize(width, height)
Description:
Resizes the properties used to describe the viewport.
This method is called automatically by the renderer during its resize handler.
Parameters:
name | type | optional | description |
---|---|---|---|
width | number | No | The new width of this WebGL Pipeline. |
height | number | No | The new height of this WebGL Pipeline. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Fires: Phaser.Renderer.WebGL.Pipelines.Events#event:RESIZE
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#resize
Source: src/renderer/webgl/WebGLPipeline.js#L966
Since: 3.0.0
restoreContext
<instance> restoreContext()
Description:
This method is called if the WebGL context is lost and restored. It ensures that uniforms are synced back to the GPU for all shaders in this pipeline.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#restoreContext
Source: src/renderer/webgl/WebGLPipeline.js#L1214
Since: 3.80.0
set1f
<instance> set1f(name, x, [shader])
Description:
Sets a 1f uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
x | number | No | The new value of the |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set1f
Source: src/renderer/webgl/WebGLPipeline.js#L2077
Since: 3.50.0
set1fv
<instance> set1fv(name, arr, [shader])
Description:
Sets a 1fv uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
arr | Array.<number> | Float32Array | No | The new value to be used for the uniform variable. |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set1fv
Source: src/renderer/webgl/WebGLPipeline.js#L2191
Since: 3.50.0
set1i
<instance> set1i(name, x, [shader])
Description:
Sets a 1i uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
x | number | No | The new value of the |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set1i
Source: src/renderer/webgl/WebGLPipeline.js#L2407
Since: 3.50.0
set1iv
<instance> set1iv(name, arr, [shader])
Description:
Sets a 1iv uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
arr | Array.<number> | Float32Array | No | The new value to be used for the uniform variable. |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set1iv
Source: src/renderer/webgl/WebGLPipeline.js#L2299
Since: 3.50.0
set2f
<instance> set2f(name, x, y, [shader])
Description:
Sets a 2f uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
x | number | No | The new X component of the |
y | number | No | The new Y component of the |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set2f
Source: src/renderer/webgl/WebGLPipeline.js#L2104
Since: 3.50.0
set2fv
<instance> set2fv(name, arr, [shader])
Description:
Sets a 2fv uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
arr | Array.<number> | Float32Array | No | The new value to be used for the uniform variable. |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set2fv
Source: src/renderer/webgl/WebGLPipeline.js#L2218
Since: 3.50.0
set2i
<instance> set2i(name, x, y, [shader])
Description:
Sets a 2i uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
x | number | No | The new X component of the |
y | number | No | The new Y component of the |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set2i
Source: src/renderer/webgl/WebGLPipeline.js#L2434
Since: 3.50.0
set2iv
<instance> set2iv(name, arr, [shader])
Description:
Sets a 2iv uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
arr | Array.<number> | Float32Array | No | The new value to be used for the uniform variable. |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set2iv
Source: src/renderer/webgl/WebGLPipeline.js#L2326
Since: 3.50.0
set3f
<instance> set3f(name, x, y, z, [shader])
Description:
Sets a 3f uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
x | number | No | The new X component of the |
y | number | No | The new Y component of the |
z | number | No | The new Z component of the |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set3f
Source: src/renderer/webgl/WebGLPipeline.js#L2132
Since: 3.50.0
set3fv
<instance> set3fv(name, arr, [shader])
Description:
Sets a 3fv uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
arr | Array.<number> | Float32Array | No | The new value to be used for the uniform variable. |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set3fv
Source: src/renderer/webgl/WebGLPipeline.js#L2245
Since: 3.50.0
set3i
<instance> set3i(name, x, y, z, [shader])
Description:
Sets a 3i uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
x | number | No | The new X component of the |
y | number | No | The new Y component of the |
z | number | No | The new Z component of the |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set3i
Source: src/renderer/webgl/WebGLPipeline.js#L2462
Since: 3.50.0
set3iv
<instance> set3iv(name, arr, [shader])
Description:
Sets a 3iv uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
arr | Array.<number> | Float32Array | No | The new value to be used for the uniform variable. |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set3iv
Source: src/renderer/webgl/WebGLPipeline.js#L2353
Since: 3.50.0
set4f
<instance> set4f(name, x, y, z, w, [shader])
Description:
Sets a 4f uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
x | number | No | X component of the uniform |
y | number | No | Y component of the uniform |
z | number | No | Z component of the uniform |
w | number | No | W component of the uniform |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set4f
Source: src/renderer/webgl/WebGLPipeline.js#L2161
Since: 3.50.0
set4fv
<instance> set4fv(name, arr, [shader])
Description:
Sets a 4fv uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
arr | Array.<number> | Float32Array | No | The new value to be used for the uniform variable. |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set4fv
Source: src/renderer/webgl/WebGLPipeline.js#L2272
Since: 3.50.0
set4i
<instance> set4i(name, x, y, z, w, [shader])
Description:
Sets a 4i uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
x | number | No | X component of the uniform. |
y | number | No | Y component of the uniform. |
z | number | No | Z component of the uniform. |
w | number | No | W component of the uniform. |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set4i
Source: src/renderer/webgl/WebGLPipeline.js#L2491
Since: 3.50.0
set4iv
<instance> set4iv(name, arr, [shader])
Description:
Sets a 4iv uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
arr | Array.<number> | Float32Array | No | The new value to be used for the uniform variable. |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#set4iv
Source: src/renderer/webgl/WebGLPipeline.js#L2380
Since: 3.50.0
setBoolean
<instance> setBoolean(name, value, [shader])
Description:
Sets a boolean uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
value | boolean | No | The new value of the |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#setBoolean
Source: src/renderer/webgl/WebGLPipeline.js#L2050
Since: 3.60.0
setGameObject
<instance> setGameObject(gameObject, [frame])
Description:
Custom pipelines can use this method in order to perform any required pre-batch tasks for the given Game Object. It must return the texture unit the Game Object was assigned.
Parameters:
name | type | optional | description |
---|---|---|---|
gameObject | No | The Game Object being rendered or added to the batch. | |
frame | Yes | Optional frame to use. Can override that of the Game Object. |
Overrides: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#setGameObject
Returns: number - The texture unit the Game Object has been assigned.
Source: src/renderer/webgl/pipelines/LightPipeline.js#L307
Since: 3.50.0
setMatrix2fv
<instance> setMatrix2fv(name, transpose, matrix, [shader])
Description:
Sets a matrix 2fv uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
transpose | boolean | No | Whether to transpose the matrix. Should be |
matrix | Array.<number> | Float32Array | No | The new values for the |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#setMatrix2fv
Source: src/renderer/webgl/WebGLPipeline.js#L2521
Since: 3.50.0
setMatrix3fv
<instance> setMatrix3fv(name, transpose, matrix, [shader])
Description:
Sets a matrix 3fv uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
transpose | boolean | No | Whether to transpose the matrix. Should be |
matrix | Float32Array | No | The new values for the |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#setMatrix3fv
Source: src/renderer/webgl/WebGLPipeline.js#L2549
Since: 3.50.0
setMatrix4fv
<instance> setMatrix4fv(name, transpose, matrix, [shader])
Description:
Sets a matrix 4fv uniform value based on the given name on the currently set shader.
The current shader is bound, before the uniform is set, making it active within the
WebGLRenderer. This means you can safely call this method from a location such as
a Scene create
or update
method. However, when working within a Shader file
directly, use the WebGLShader
method equivalent instead, to avoid the program
being set.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
transpose | boolean | No | Whether to transpose the matrix. Should be |
matrix | Float32Array | No | The matrix data. If using a Matrix4 this should be the |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#setMatrix4fv
Source: src/renderer/webgl/WebGLPipeline.js#L2577
Since: 3.50.0
setNormalMapRotation
<instance> setNormalMapRotation(rotation)
Description:
Rotates the normal map vectors inversely by the given angle. Only works in 2D space.
Parameters:
name | type | optional | description |
---|---|---|---|
rotation | number | No | The angle of rotation in radians. |
Source: src/renderer/webgl/pipelines/LightPipeline.js#L211
Since: 3.16.0
setProjectionMatrix
<instance> setProjectionMatrix(width, height)
Description:
Adjusts this pipelines ortho Projection Matrix to use the given dimensions
and resets the uProjectionMatrix
uniform on all bound shaders.
This method is called automatically by the renderer during its resize handler.
Parameters:
name | type | optional | description |
---|---|---|---|
width | number | No | The new width of this WebGL Pipeline. |
height | number | No | The new height of this WebGL Pipeline. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#setProjectionMatrix
Source: src/renderer/webgl/WebGLPipeline.js#L1011
Since: 3.50.0
setShader
<instance> setShader(shader, [setAttributes], [vertexBuffer])
Description:
Sets the currently active shader within this pipeline.
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
shader | No | The shader to set as being current. | ||
setAttributes | boolean | Yes | false | Should the vertex attribute pointers be set? |
vertexBuffer | Yes | The vertex buffer to be set before the shader is bound. Defaults to the one owned by this pipeline. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#setShader
Source: src/renderer/webgl/WebGLPipeline.js#L627
Since: 3.50.0
setShadersFromConfig
<instance> setShadersFromConfig(config)
Description:
Destroys all shaders currently set in the WebGLPipeline.shaders
array and then parses the given
config
object, extracting the shaders from it, creating WebGLShader
instances and finally
setting them into the shaders
array of this pipeline.
This is a destructive process. Be very careful when you call it, should you need to.
Parameters:
name | type | optional | description |
---|---|---|---|
config | No | The configuration object for this WebGL Pipeline. |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#setShadersFromConfig
Source: src/renderer/webgl/WebGLPipeline.js#L685
Since: 3.50.0
setTexture2D
<instance> setTexture2D([texture], [gameObject])
Description:
Assigns a texture to the current batch. If a different texture is already set it creates a new batch object.
Parameters:
name | type | optional | description |
---|---|---|---|
texture | Yes | Texture that will be assigned to the current batch. If not given uses blankTexture. | |
gameObject | Yes | The Game Object being rendered or added to the batch. |
Overrides: Phaser.Renderer.WebGL.Pipelines.MultiPipeline#setTexture2D
Source: src/renderer/webgl/pipelines/LightPipeline.js#L253
Since: 3.50.0
setTime
<instance> setTime(name, [shader])
Description:
Sets the current duration into a 1f uniform value based on the given name.
This can be used for mapping time uniform values, such as iTime
.
Parameters:
name | type | optional | description |
---|---|---|---|
name | string | No | The name of the uniform to set. |
shader | Yes | The shader to set the value on. If not given, the |
Returns: Phaser.Renderer.WebGL.Pipelines.LightPipeline - This WebGLPipeline instance.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#setTime
Source: src/renderer/webgl/WebGLPipeline.js#L2030
Since: 3.50.0
setVertexBuffer
<instance> setVertexBuffer([buffer])
Description:
Binds the vertex buffer to be the active ARRAY_BUFFER on the WebGL context.
It first checks to see if it's already set as the active buffer and only binds itself if not.
Parameters:
name | type | optional | description |
---|---|---|---|
buffer | Yes | The Vertex Buffer to be bound. Defaults to the one owned by this pipeline. |
Returns: boolean - true
if the vertex buffer was bound, or false
if it was already bound.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#setVertexBuffer
Source: src/renderer/webgl/WebGLPipeline.js#L1251
Since: 3.50.0
shouldFlush
<instance> shouldFlush([amount])
Description:
Check if the current batch of vertices is full.
You can optionally provide an amount
parameter. If given, it will check if the batch
needs to flush if the amount
is added to it. This allows you to test if you should
flush before populating the batch.
Parameters:
name | type | optional | default | description |
---|---|---|---|---|
amount | number | Yes | 0 | Will the batch need to flush if this many vertices are added to it? |
Returns: boolean - true
if the current batch should be flushed, otherwise false
.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#shouldFlush
Source: src/renderer/webgl/WebGLPipeline.js#L931
Since: 3.0.0
shutdown
<instance> shutdown()
Description:
Removes all listeners.
Inherits: Phaser.Events.EventEmitter#shutdown
Source: src/events/EventEmitter.js#L31
Since: 3.0.0
unbind
<instance> unbind()
Description:
This method is called every time the Pipeline Manager deactivates this pipeline, swapping from
it to another one. This happens after a call to flush
and before the new pipeline is bound.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#unbind
Source: src/renderer/webgl/WebGLPipeline.js#L1355
Since: 3.50.0
updateProjectionMatrix
<instance> updateProjectionMatrix()
Description:
Adjusts this pipelines ortho Projection Matrix to match that of the global WebGL Renderer Projection Matrix.
This method is called automatically by the Pipeline Manager when this pipeline is set.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#updateProjectionMatrix
Source: src/renderer/webgl/WebGLPipeline.js#L1096
Since: 3.50.0
vertexAvailable
<instance> vertexAvailable()
Description:
Returns the number of vertices that can be added to the current batch before it will trigger a flush to happen.
Returns: number - The number of vertices that can still be added to the current batch before it will flush.
Inherits: Phaser.Renderer.WebGL.WebGLPipeline#vertexAvailable
Source: src/renderer/webgl/WebGLPipeline.js#L952
Since: 3.60.0