Renamed the pipelines to make them less ambiguous and sorted out lots of config properties

This commit is contained in:
Richard Davey 2020-08-21 16:01:39 +01:00
parent 8f5ee5391f
commit 57040554ef
5 changed files with 266 additions and 194 deletions

View file

@ -6,47 +6,81 @@
*/
var Class = require('../../../utils/Class');
var ShaderSourceFS = require('../shaders/ForwardDiffuse-frag.js');
var TextureTintPipeline = require('./TextureTintPipeline');
var GetFastValue = require('../../../utils/object/GetFastValue');
var ShaderSourceFS = require('../shaders/Light-frag.js');
var MultiPipeline = require('./MultiPipeline');
var WebGLPipeline = require('../WebGLPipeline');
var LIGHT_COUNT = 10;
/**
* @classdesc
* ForwardDiffuseLightPipeline implements a forward rendering approach for 2D lights.
*
* It works by using a custom shader, combined with Light Game Objects, that provides an ambient
* illumination effect in your games.
* 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.
*
* This pipeline extends TextureTintPipeline so it implements all of its rendering functions and batching system.
* The shader works in tandem with Light Game Objects, and optionally texture normal maps,
* to provide an ambient illumination effect.
*
* @class ForwardDiffuseLightPipeline
* @extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline
* 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:
*
* `uProjectionMatrix` (mat4)
* `uViewMatrix` (mat4)
* `uModelMatrix` (mat4)
* `uMainSampler` (sampler2D)
* `uNormSampler` (sampler2D)
* `uCamera` (vec4)
* `uResolution` (vec2)
* `uAmbientLightColor` (vec3)
* `uInverseRotationMatrix` (mat3)
* `uLights` (Light struct)
*
* @class LightPipeline
* @extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline
* @memberof Phaser.Renderer.WebGL.Pipelines
* @constructor
* @since 3.0.0
* @since 3.50.0
*
* @param {object} config - The configuration of the pipeline, same as the {@link Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline}. The fragment shader will be replaced with the lighting shader.
* @param {Phaser.Types.Renderer.WebGL.WebGLPipelineConfig} config - The configuration options for this pipeline.
*/
var ForwardDiffuseLightPipeline = new Class({
var LightPipeline = new Class({
Extends: TextureTintPipeline,
Extends: MultiPipeline,
initialize:
function ForwardDiffuseLightPipeline (config)
function LightPipeline (config)
{
LIGHT_COUNT = config.maxLights;
LIGHT_COUNT = config.game.renderer.config.maxLights;
config.fragShader = ShaderSourceFS.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString());
var fragmentShaderSource = GetFastValue(config, 'fragShader', ShaderSourceFS);
TextureTintPipeline.call(this, config);
config.fragShader = fragmentShaderSource.replace('%LIGHT_COUNT%', LIGHT_COUNT.toString());
MultiPipeline.call(this, config);
/**
* Inverse rotation matrix for normal map rotations.
*
* @name Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#inverseRotationMatrix
* @name Phaser.Renderer.WebGL.Pipelines.LightPipeline#inverseRotationMatrix
* @type {Float32Array}
* @private
* @since 3.16.0
@ -61,7 +95,7 @@ var ForwardDiffuseLightPipeline = new Class({
* Stores a default normal map, which is an object with a `glTexture` property that
* maps to a 1x1 texture of the color #7f7fff created in the `boot` method.
*
* @name Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#defaultNormalMap
* @name Phaser.Renderer.WebGL.Pipelines.LightPipeline#defaultNormalMap
* @type {object}
* @since 3.50.0
*/
@ -70,7 +104,7 @@ var ForwardDiffuseLightPipeline = new Class({
/**
* Stores the previous number of lights rendered.
*
* @name Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#lightCount
* @name Phaser.Renderer.WebGL.Pipelines.LightPipeline#lightCount
* @type {number}
* @since 3.50.0
*/
@ -85,7 +119,7 @@ var ForwardDiffuseLightPipeline = new Class({
* 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.
*
* @method Phaser.Renderer.WebGL.ForwardDiffuseLightPipeline#boot
* @method Phaser.Renderer.WebGL.LightPipeline#boot
* @since 3.11.0
*/
boot: function ()
@ -112,7 +146,7 @@ var ForwardDiffuseLightPipeline = new Class({
* Sets the shader program, vertex buffer and other resources.
* Should only be called when changing pipeline.
*
* @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#bind
* @method Phaser.Renderer.WebGL.Pipelines.LightPipeline#bind
* @since 3.50.0
*
* @return {this} This WebGLPipeline instance.
@ -134,7 +168,7 @@ var ForwardDiffuseLightPipeline = new Class({
/**
* This function sets all the needed resources for each camera pass.
*
* @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#onRender
* @method Phaser.Renderer.WebGL.Pipelines.LightPipeline#onRender
* @since 3.0.0
*
* @param {Phaser.Scene} scene - The Scene being rendered.
@ -218,7 +252,7 @@ var ForwardDiffuseLightPipeline = new Class({
* Rotates the normal map vectors inversely by the given angle.
* Only works in 2D space.
*
* @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#setNormalMapRotation
* @method Phaser.Renderer.WebGL.Pipelines.LightPipeline#setNormalMapRotation
* @since 3.16.0
*
* @param {number} rotation - The angle of rotation in radians.
@ -259,7 +293,7 @@ var ForwardDiffuseLightPipeline = new Class({
/**
* Assigns a texture to the current batch. If a different texture is already set it creates a new batch object.
*
* @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#setTexture2D
* @method Phaser.Renderer.WebGL.Pipelines.LightPipeline#setTexture2D
* @since 3.50.0
*
* @param {WebGLTexture} [texture] - WebGLTexture that will be assigned to the current batch. If not given uses blankTexture.
@ -294,7 +328,7 @@ var ForwardDiffuseLightPipeline = new Class({
* 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.
*
* @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#setGameObject
* @method Phaser.Renderer.WebGL.Pipelines.LightPipeline#setGameObject
* @since 3.50.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object being rendered or added to the batch.
@ -329,7 +363,7 @@ var ForwardDiffuseLightPipeline = new Class({
* Returns the normal map WebGLTexture from the given Game Object.
* If the Game Object doesn't have one, it returns the default normal map from this pipeline instead.
*
* @method Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline#getNormalMap
* @method Phaser.Renderer.WebGL.Pipelines.LightPipeline#getNormalMap
* @since 3.50.0
*
* @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object to get the normal map from.
@ -374,6 +408,6 @@ var ForwardDiffuseLightPipeline = new Class({
});
ForwardDiffuseLightPipeline.LIGHT_COUNT = LIGHT_COUNT;
LightPipeline.LIGHT_COUNT = LIGHT_COUNT;
module.exports = ForwardDiffuseLightPipeline;
module.exports = LightPipeline;

View file

@ -10,35 +10,65 @@ var Earcut = require('../../../geom/polygon/Earcut');
var GetFastValue = require('../../../utils/object/GetFastValue');
var ModelViewProjection = require('./components/ModelViewProjection');
var ProjectOrtho = require('../mvp/ProjectOrtho');
var ShaderSourceFS = require('../shaders/TextureTint-frag.js');
var ShaderSourceVS = require('../shaders/TextureTint-vert.js');
var ShaderSourceFS = require('../shaders/Multi-frag.js');
var ShaderSourceVS = require('../shaders/Multi-vert.js');
var TransformMatrix = require('../../../gameobjects/components/TransformMatrix');
var Utils = require('../Utils');
var WebGLPipeline = require('../WebGLPipeline');
/**
* @classdesc
* TextureTintPipeline implements the rendering infrastructure
* for displaying textured objects
* The config properties are:
* - game: Current game instance.
* - renderer: Current WebGL renderer.
* - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES.
* Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants).
* - vertShader: Source for vertex shader as a string.
* - fragShader: Source for fragment shader as a string.
* - vertexCapacity: The amount of vertices that shall be allocated
* - vertexSize: The size of a single vertex in bytes.
*
* @class TextureTintPipeline
* The Multi Pipeline is the core 2D texture rendering pipeline used by Phaser in WebGL.
* Virtually all Game Objects use this pipeline by default, including Sprites, Graphics
* and Tilemaps. It handles the batching of quads and tris, as well as methods for
* drawing and batching geometry data.
*
* Prior to Phaser v3.50 this pipeline was called the `TextureTintPipeline`.
*
* In previous versions of Phaser only one single texture unit was supported at any one time.
* The Multi Pipeline is an evolution of the old Texture Tint Pipeline, updated to support
* multi-textures for increased performance.
*
* The fragment shader it uses can be found in `shaders/src/Multi.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:
*
* `uProjectionMatrix` (mat4)
* `uViewMatrix` (mat4)
* `uModelMatrix` (mat4)
* `uMainSampler` (sampler2D array)
*
* If you wish to create a custom pipeline extending from this one, you can use two string
* declarations in your fragment shader source: `%count%` and `%forloop%`, where `count` is
* used to set the number of `sampler2Ds` available, and `forloop` is a block of GLSL code
* that will get the currently bound texture unit.
*
* This pipeline will automatically inject that code for you, should those values exist
* in your shader source. If you wish to handle this yourself, you can also use the
* function `Utils.parseFragmentShaderMaxTextures`.
*
* If you wish to create a pipeline that works from a single texture, or that doesn't have
* internal texture iteration, please see the `SinglePipeline` instead.
*
* @class MultiPipeline
* @extends Phaser.Renderer.WebGL.WebGLPipeline
* @memberof Phaser.Renderer.WebGL.Pipelines
* @constructor
* @since 3.0.0
* @since 3.50.0
*
* @param {object} config - The configuration options for this Texture Tint Pipeline, as described above.
* @param {Phaser.Types.Renderer.WebGL.WebGLPipelineConfig} config - The configuration options for this pipeline.
*/
var TextureTintPipeline = new Class({
var MultiPipeline = new Class({
Extends: WebGLPipeline,
@ -48,87 +78,71 @@ var TextureTintPipeline = new Class({
initialize:
function TextureTintPipeline (config)
function MultiPipeline (config)
{
var rendererConfig = config.renderer.config;
var renderer = config.game.renderer;
var gl = renderer.gl;
var fragmentShaderSource;
var maxTextures = config.renderer.maxTextures;
var fragmentShaderSource = GetFastValue(config, 'fragShader', ShaderSourceFS);
if (!config.fragShader)
{
fragmentShaderSource = Utils.parseFragmentShaderMaxTextures(ShaderSourceFS, maxTextures);
}
else
{
fragmentShaderSource = config.fragShader;
}
// Vertex Size = attribute size added together (2 + 2 + 1 + 4)
// Vertex Size = attribute size added together (2 + 2 + 1 + 1 + 4) inc maxTextures
WebGLPipeline.call(this, {
game: config.game,
renderer: config.renderer,
gl: config.renderer.gl,
topology: GetFastValue(config, 'topology', config.renderer.gl.TRIANGLES),
vertShader: GetFastValue(config, 'vertShader', ShaderSourceVS),
fragShader: GetFastValue(config, 'fragShader', fragmentShaderSource),
vertexCapacity: GetFastValue(config, 'vertexCapacity', 6 * rendererConfig.batchSize),
vertexSize: GetFastValue(config, 'vertexSize', Float32Array.BYTES_PER_ELEMENT * 6 + Uint8Array.BYTES_PER_ELEMENT * 4),
attributes: [
{
name: 'inPosition',
size: 2,
type: config.renderer.gl.FLOAT,
normalized: false,
offset: 0,
enabled: false,
location: -1
},
{
name: 'inTexCoord',
size: 2,
type: config.renderer.gl.FLOAT,
normalized: false,
offset: 4 * 2,
enabled: false,
location: -1
},
{
name: 'inTexId',
size: 1,
type: config.renderer.gl.FLOAT,
normalized: false,
offset: 4 * 4,
enabled: false,
location: -1
},
{
name: 'inTintEffect',
size: 1,
type: config.renderer.gl.FLOAT,
normalized: false,
offset: 4 * 5,
enabled: false,
location: -1
},
{
name: 'inTint',
size: 4,
type: config.renderer.gl.UNSIGNED_BYTE,
normalized: true,
offset: 4 * 6,
enabled: false,
location: -1
}
]
});
config.fragShader = Utils.parseFragmentShaderMaxTextures(fragmentShaderSource, renderer.maxTextures);
config.vertShader = GetFastValue(config, 'vertShader', ShaderSourceVS);
config.attributes = GetFastValue(config, 'attributes', [
{
name: 'inPosition',
size: 2,
type: gl.FLOAT,
normalized: false,
offset: 0,
enabled: false,
location: -1
},
{
name: 'inTexCoord',
size: 2,
type: gl.FLOAT,
normalized: false,
offset: 8,
enabled: false,
location: -1
},
{
name: 'inTexId',
size: 1,
type: gl.FLOAT,
normalized: false,
offset: 16,
enabled: false,
location: -1
},
{
name: 'inTintEffect',
size: 1,
type: gl.FLOAT,
normalized: false,
offset: 20,
enabled: false,
location: -1
},
{
name: 'inTint',
size: 4,
type: gl.UNSIGNED_BYTE,
normalized: true,
offset: 24,
enabled: false,
location: -1
}
]);
WebGLPipeline.call(this, config);
/**
* Float32 view of the array buffer containing the pipeline's vertices.
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewF32
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#vertexViewF32
* @type {Float32Array}
* @since 3.0.0
*/
@ -137,7 +151,7 @@ var TextureTintPipeline = new Class({
/**
* Uint32 view of the array buffer containing the pipeline's vertices.
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#vertexViewU32
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#vertexViewU32
* @type {Uint32Array}
* @since 3.0.0
*/
@ -146,7 +160,7 @@ var TextureTintPipeline = new Class({
/**
* A temporary Transform Matrix, re-used internally during batching.
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix1
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#_tempMatrix1
* @private
* @type {Phaser.GameObjects.Components.TransformMatrix}
* @since 3.11.0
@ -156,7 +170,7 @@ var TextureTintPipeline = new Class({
/**
* A temporary Transform Matrix, re-used internally during batching.
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix2
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#_tempMatrix2
* @private
* @type {Phaser.GameObjects.Components.TransformMatrix}
* @since 3.11.0
@ -166,7 +180,7 @@ var TextureTintPipeline = new Class({
/**
* A temporary Transform Matrix, re-used internally during batching.
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix3
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#_tempMatrix3
* @private
* @type {Phaser.GameObjects.Components.TransformMatrix}
* @since 3.11.0
@ -176,7 +190,7 @@ var TextureTintPipeline = new Class({
/**
* A temporary Transform Matrix, re-used internally during batching.
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#_tempMatrix4
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#_tempMatrix4
* @private
* @type {Phaser.GameObjects.Components.TransformMatrix}
* @since 3.11.0
@ -186,7 +200,7 @@ var TextureTintPipeline = new Class({
/**
* Used internally to draw stroked triangles.
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#tempTriangle
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#tempTriangle
* @type {array}
* @private
* @since 3.12.0
@ -206,7 +220,7 @@ var TextureTintPipeline = new Class({
* 2 = solid color, no texture
* 3 = solid texture, no color
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#tintEffect
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#tintEffect
* @type {number}
* @private
* @since 3.12.0
@ -216,7 +230,7 @@ var TextureTintPipeline = new Class({
/**
* Cached stroke tint.
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#strokeTint
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#strokeTint
* @type {object}
* @private
* @since 3.12.0
@ -226,7 +240,7 @@ var TextureTintPipeline = new Class({
/**
* Cached fill tint.
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#fillTint
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#fillTint
* @type {object}
* @private
* @since 3.12.0
@ -236,7 +250,7 @@ var TextureTintPipeline = new Class({
/**
* Internal texture frame reference.
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#currentFrame
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#currentFrame
* @type {Phaser.Textures.Frame}
* @private
* @since 3.12.0
@ -246,7 +260,7 @@ var TextureTintPipeline = new Class({
/**
* Internal path quad cache.
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#firstQuad
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#firstQuad
* @type {array}
* @private
* @since 3.12.0
@ -256,7 +270,7 @@ var TextureTintPipeline = new Class({
/**
* Internal path quad cache.
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#prevQuad
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#prevQuad
* @type {array}
* @private
* @since 3.12.0
@ -266,7 +280,7 @@ var TextureTintPipeline = new Class({
/**
* Used internally for triangulating a polygon.
*
* @name Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#polygonCache
* @name Phaser.Renderer.WebGL.Pipelines.MultiPipeline#polygonCache
* @type {array}
* @private
* @since 3.12.0
@ -281,7 +295,7 @@ var TextureTintPipeline = new Class({
* Sets the shader program, vertex buffer and other resources.
* Should only be called when changing pipeline.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#bind
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#bind
* @since 3.50.0
*
* @return {this} This WebGLPipeline instance.
@ -298,7 +312,7 @@ var TextureTintPipeline = new Class({
/**
* Called every time a Game Object needs to use this pipeline.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#onBind
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#onBind
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} [gameObject] - The Game Object that invoked this pipeline, if any.
@ -315,7 +329,7 @@ var TextureTintPipeline = new Class({
/**
* Resizes this pipeline and updates the projection.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#resize
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#resize
* @since 3.0.0
*
* @param {number} width - The new width.
@ -336,7 +350,7 @@ var TextureTintPipeline = new Class({
/**
* Assigns a texture to the current batch. If a different texture is already set it creates a new batch object.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#setTexture2D
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#setTexture2D
* @since 3.1.0
*
* @param {WebGLTexture} [texture] - WebGLTexture that will be assigned to the current batch. If not given uses blankTexture.
@ -355,7 +369,7 @@ var TextureTintPipeline = new Class({
/**
* Uploads the vertex data and emits a draw call for the current batch of vertices.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#flush
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#flush
* @since 3.0.0
*
* @return {this} This WebGLPipeline instance.
@ -388,7 +402,7 @@ var TextureTintPipeline = new Class({
/**
* Takes a Sprite Game Object, or any object that extends it, and adds it to the batch.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchSprite
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchSprite
* @since 3.0.0
*
* @param {(Phaser.GameObjects.Image|Phaser.GameObjects.Sprite)} sprite - The texture based Game Object to add to the batch.
@ -561,7 +575,7 @@ var TextureTintPipeline = new Class({
*
* Where tx0/ty0 = 0, tx1/ty1 = 1, tx2/ty2 = 2 and tx3/ty3 = 3
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchQuad
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchQuad
* @since 3.12.0
*
* @param {number} x0 - The top-left x position.
@ -674,7 +688,7 @@ var TextureTintPipeline = new Class({
* 1-----2
* ```
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTri
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchTri
* @since 3.12.0
*
* @param {number} x1 - The bottom-left x position.
@ -748,7 +762,7 @@ var TextureTintPipeline = new Class({
/**
* Generic function for batching a textured quad using argument values instead of a Game Object.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTexture
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchTexture
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - Source GameObject.
@ -938,7 +952,7 @@ var TextureTintPipeline = new Class({
/**
* Adds a Texture Frame into the batch for rendering.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchTextureFrame
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchTextureFrame
* @since 3.12.0
*
* @param {Phaser.Textures.Frame} frame - The Texture Frame to be rendered.
@ -1003,7 +1017,7 @@ var TextureTintPipeline = new Class({
*
* Used for directly batching untransformed rectangles, such as Camera background colors.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#drawFillRect
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#drawFillRect
* @since 3.12.0
*
* @param {number} x - Horizontal top left coordinate of the rectangle.
@ -1034,7 +1048,7 @@ var TextureTintPipeline = new Class({
* Pushes a filled rectangle into the vertex batch.
* Rectangle factors in the given transform matrices before adding to the batch.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillRect
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchFillRect
* @since 3.12.0
*
* @param {number} x - Horizontal top left coordinate of the rectangle.
@ -1087,7 +1101,7 @@ var TextureTintPipeline = new Class({
* Pushes a filled triangle into the vertex batch.
* Triangle factors in the given transform matrices before adding to the batch.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillTriangle
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchFillTriangle
* @since 3.12.0
*
* @param {number} x0 - Point 0 x coordinate.
@ -1135,7 +1149,7 @@ var TextureTintPipeline = new Class({
* 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.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchStrokeTriangle
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchStrokeTriangle
* @since 3.12.0
*
* @param {number} x0 - Point 0 x coordinate.
@ -1179,7 +1193,7 @@ var TextureTintPipeline = new Class({
*
* The path is always automatically closed because it's filled.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchFillPath
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchFillPath
* @since 3.12.0
*
* @param {array} path - Collection of points that represent the path.
@ -1260,7 +1274,7 @@ var TextureTintPipeline = new Class({
*
* The path is optionally closed at the end.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchStrokePath
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchStrokePath
* @since 3.12.0
*
* @param {array} path - Collection of points that represent the path.
@ -1304,7 +1318,7 @@ var TextureTintPipeline = new Class({
* Creates a line out of 4 quads and adds it to the vertex batch based on the given line values.
* Assumes a texture has already been set, prior to calling this function.
*
* @method Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline#batchLine
* @method Phaser.Renderer.WebGL.Pipelines.MultiPipeline#batchLine
* @since 3.12.0
*
* @param {number} ax - X coordinate to the start of the line
@ -1420,4 +1434,4 @@ var TextureTintPipeline = new Class({
});
module.exports = TextureTintPipeline;
module.exports = MultiPipeline;

View file

@ -0,0 +1,66 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../../utils/Class');
var ModelViewProjection = require('./components/ModelViewProjection');
var MultiPipeline = require('./MultiPipeline');
/**
* @classdesc
*
* The Rope Pipeline is a variation of the Multi Pipeline that uses a `TRIANGLE_STRIP` for
* its topology, instead of TRIANGLES. This is primarily used by the Rope Game Object,
* or anything that extends it.
*
* Prior to Phaser v3.50 this pipeline was called the `TextureTintStripPipeline`.
*
* The fragment shader it uses can be found in `shaders/src/Multi.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:
*
* `uProjectionMatrix` (mat4)
* `uViewMatrix` (mat4)
* `uModelMatrix` (mat4)
* `uMainSampler` (sampler2D array)
*
* The pipeline is structurally identical to the Multi Pipeline and should be treated as such.
*
* @class RopePipeline
* @extends Phaser.Renderer.WebGL.Pipelines.MultiPipeline
* @memberof Phaser.Renderer.WebGL.Pipelines
* @constructor
* @since 3.50.0
*
* @param {Phaser.Types.Renderer.WebGL.WebGLPipelineConfig} config - The configuration options for this pipeline.
*/
var RopePipeline = new Class({
Extends: MultiPipeline,
Mixins: [
ModelViewProjection
],
initialize:
function RopePipeline (config)
{
config.topology = config.renderer.gl.TRIANGLE_STRIP;
MultiPipeline.call(this, config);
}
});
module.exports = RopePipeline;

View file

@ -1,43 +0,0 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @author Felipe Alfonso <@bitnenfer>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../../utils/Class');
var ModelViewProjection = require('./components/ModelViewProjection');
var TextureTintPipeline = require('./TextureTintPipeline');
/**
* @classdesc
* The Texture Tint Strip Pipeline is a variation of the Texture Tint Pipeline that uses a TRIANGLE_STRIP for
* its topology, instead of TRIANGLES. This is primarily used by the Rope Game Object any anything that extends it.
*
* @class TextureTintStripPipeline
* @extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline
* @memberof Phaser.Renderer.WebGL.Pipelines
* @constructor
* @since 3.23.0
*
* @param {object} config - The configuration options for this Texture Tint Pipeline, as described above.
*/
var TextureTintStripPipeline = new Class({
Extends: TextureTintPipeline,
Mixins: [
ModelViewProjection
],
initialize:
function TextureTintStripPipeline (config)
{
config.topology = config.renderer.gl.TRIANGLE_STRIP;
TextureTintPipeline.call(this, config);
}
});
module.exports = TextureTintStripPipeline;

View file

@ -11,9 +11,10 @@
module.exports = {
BitmapMaskPipeline: require('./BitmapMaskPipeline'),
ForwardDiffuseLightPipeline: require('./ForwardDiffuseLightPipeline'),
TextureTintPipeline: require('./TextureTintPipeline'),
TextureTintStripPipeline: require('./TextureTintStripPipeline'),
LightPipeline: require('./LightPipeline'),
SinglePipeline: require('./SinglePipeline'),
MultiPipeline: require('./MultiPipeline'),
RopePipeline: require('./RopePipeline'),
ModelViewProjection: require('./components/ModelViewProjection')
};