Removed un-needed Quad Pipeline and shaders

This commit is contained in:
Richard Davey 2019-04-25 12:13:09 +01:00
parent f37a61de27
commit 2ff76eb4b5
7 changed files with 0 additions and 367 deletions

View file

@ -19,7 +19,6 @@ var WebGLSnapshot = require('../snapshot/WebGLSnapshot');
// Default Pipelines // Default Pipelines
var BitmapMaskPipeline = require('./pipelines/BitmapMaskPipeline'); var BitmapMaskPipeline = require('./pipelines/BitmapMaskPipeline');
var ForwardDiffuseLightPipeline = require('./pipelines/ForwardDiffuseLightPipeline'); var ForwardDiffuseLightPipeline = require('./pipelines/ForwardDiffuseLightPipeline');
var QuadShaderPipeline = require('./pipelines/QuadShaderPipeline');
var TextureTintPipeline = require('./pipelines/TextureTintPipeline'); var TextureTintPipeline = require('./pipelines/TextureTintPipeline');
/** /**
@ -605,7 +604,6 @@ var WebGLRenderer = new Class({
this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: game, renderer: this })); this.addPipeline('TextureTintPipeline', new TextureTintPipeline({ game: game, renderer: this }));
this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: game, renderer: this })); this.addPipeline('BitmapMaskPipeline', new BitmapMaskPipeline({ game: game, renderer: this }));
this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: game, renderer: this, maxLights: config.maxLights })); this.addPipeline('Light2D', new ForwardDiffuseLightPipeline({ game: game, renderer: this, maxLights: config.maxLights }));
this.addPipeline('QuadShaderPipeline', new QuadShaderPipeline({ game: game, renderer: this }));
this.setBlendMode(CONST.BlendModes.NORMAL); this.setBlendMode(CONST.BlendModes.NORMAL);

View file

@ -1,238 +0,0 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2019 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var Class = require('../../../utils/Class');
var ModelViewProjection = require('./components/ModelViewProjection');
var ShaderSourceFS = require('../shaders/QuadShader-frag.js');
var ShaderSourceVS = require('../shaders/QuadShader-vert.js');
var TransformMatrix = require('../../../gameobjects/components/TransformMatrix');
var WebGLPipeline = require('../WebGLPipeline');
/**
* @classdesc
*
* A single quad with its own custom shader applied to it.
* The quad can have a size, position, rotation and scale.
*
* Once the quad is drawn the batch is flushed. There is no batching of these objects.
*
* @class QuadShaderPipeline
* @extends Phaser.Renderer.WebGL.WebGLPipeline
* @memberof Phaser.Renderer.WebGL.Pipelines
* @constructor
* @since 3.17.0
*
* @param {object} config - The configuration options for this Pipeline, as described above.
*/
var QuadShaderPipeline = new Class({
Extends: WebGLPipeline,
Mixins: [
ModelViewProjection
],
initialize:
function QuadShaderPipeline (config)
{
WebGLPipeline.call(this, {
game: config.game,
renderer: config.renderer,
gl: config.renderer.gl,
topology: config.renderer.gl.TRIANGLES,
vertShader: ShaderSourceVS,
fragShader: ShaderSourceFS,
vertexCapacity: 6,
vertexSize: Float32Array.BYTES_PER_ELEMENT * 2,
attributes: [
{
name: 'inPosition',
size: 2,
type: config.renderer.gl.FLOAT,
normalized: false,
offset: 0
}
]
});
/**
* Float32 view of the array buffer containing the pipeline's vertices.
*
* @name Phaser.Renderer.WebGL.Pipelines.QuadShaderPipeline#vertexViewF32
* @type {Float32Array}
* @since 3.17.0
*/
this.vertexViewF32 = new Float32Array(this.vertexData);
/**
* A temporary Transform Matrix, re-used internally during batching.
*
* @name Phaser.Renderer.WebGL.Pipelines.QuadShaderPipeline#_tempMatrix1
* @private
* @type {Phaser.GameObjects.Components.TransformMatrix}
* @since 3.17.0
*/
this._tempMatrix1 = new TransformMatrix();
/**
* A temporary Transform Matrix, re-used internally during batching.
*
* @name Phaser.Renderer.WebGL.Pipelines.QuadShaderPipeline#_tempMatrix2
* @private
* @type {Phaser.GameObjects.Components.TransformMatrix}
* @since 3.17.0
*/
this._tempMatrix2 = new TransformMatrix();
/**
* A temporary Transform Matrix, re-used internally during batching.
*
* @name Phaser.Renderer.WebGL.Pipelines.QuadShaderPipeline#_tempMatrix3
* @private
* @type {Phaser.GameObjects.Components.TransformMatrix}
* @since 3.17.0
*/
this._tempMatrix3 = new TransformMatrix();
/**
* A temporary Transform Matrix, re-used internally during batching.
*
* @name Phaser.Renderer.WebGL.Pipelines.QuadShaderPipeline#_tempMatrix4
* @private
* @type {Phaser.GameObjects.Components.TransformMatrix}
* @since 3.17.0
*/
this._tempMatrix4 = new TransformMatrix();
this.defaultProgram = this.program;
this.mvpInit();
},
/**
* Called every time the pipeline needs to be used.
* It binds all necessary resources.
*
* @method Phaser.Renderer.WebGL.Pipelines.QuadShaderPipeline#bind
* @since 3.17.0
*
* @return {this} This WebGLPipeline instance.
*/
// bind: function ()
// {
// WebGLPipeline.prototype.bind.call(this);
// },
/**
* Resizes this pipeline and updates the projection.
*
* @method Phaser.Renderer.WebGL.Pipelines.QuadShaderPipeline#resize
* @since 3.17.0
*
* @param {number} width - The new width.
* @param {number} height - The new height.
* @param {number} resolution - The resolution.
*
* @return {this} This WebGLPipeline instance.
*/
resize: function (width, height, resolution)
{
WebGLPipeline.prototype.resize.call(this, width, height, resolution);
this.projOrtho(0, this.width, this.height, 0, -1000.0, 1000.0);
return this;
},
/**
* Uploads the vertex data and emits a draw call for the current batch of vertices.
*
* @method Phaser.Renderer.WebGL.Pipelines.QuadShaderPipeline#flush
* @since 3.17.0
*
* @return {this} This WebGLPipeline instance.
*/
flush: function ()
{
if (this.flushLocked)
{
return this;
}
var gl = this.gl;
var vertexCount = 6;
var topology = this.topology;
var vertexSize = this.vertexSize;
gl.bufferSubData(gl.ARRAY_BUFFER, 0, this.bytes.subarray(0, vertexCount * vertexSize));
// 0 = first batch index
// 6 = batchVertexCount
gl.drawArrays(topology, 0, vertexCount);
return this;
},
/**
* Renders a single quad using the current shader and then flushes the batch.
*
* @method Phaser.Renderer.WebGL.Pipelines.QuadShaderPipeline#draw
* @since 3.17.0
*
* @param {number} x - Horizontal top left coordinate of the rectangle.
* @param {number} y - Vertical top left coordinate of the rectangle.
* @param {number} width - Width of the rectangle.
* @param {number} height - Height of the rectangle.
* @param {Phaser.GameObjects.Components.TransformMatrix} currentMatrix - The current transform.
* @param {Phaser.GameObjects.Components.TransformMatrix} parentMatrix - The parent transform.
*/
draw: function (x, y, width, height, currentMatrix, parentMatrix)
{
var calcMatrix = this._tempMatrix3;
// Multiply and store result in calcMatrix, only if the parentMatrix is set, otherwise we'll use whatever values are already in the calcMatrix
if (parentMatrix)
{
parentMatrix.multiply(currentMatrix, calcMatrix);
}
var xw = x + width;
var yh = y + height;
var x0 = calcMatrix.getX(x, y);
var y0 = calcMatrix.getY(x, y);
var x1 = calcMatrix.getX(x, yh);
var y1 = calcMatrix.getY(x, yh);
var x2 = calcMatrix.getX(xw, yh);
var y2 = calcMatrix.getY(xw, yh);
var x3 = calcMatrix.getX(xw, y);
var y3 = calcMatrix.getY(xw, y);
var vertexViewF32 = this.vertexViewF32;
vertexViewF32[0] = x0;
vertexViewF32[1] = y0;
vertexViewF32[2] = x1;
vertexViewF32[3] = y1;
vertexViewF32[4] = x2;
vertexViewF32[5] = y2;
vertexViewF32[6] = x0;
vertexViewF32[7] = y0;
vertexViewF32[8] = x2;
vertexViewF32[9] = y2;
vertexViewF32[10] = x3;
vertexViewF32[11] = y3;
this.flush();
}
});
module.exports = QuadShaderPipeline;

View file

@ -12,7 +12,6 @@ module.exports = {
BitmapMaskPipeline: require('./BitmapMaskPipeline'), BitmapMaskPipeline: require('./BitmapMaskPipeline'),
ForwardDiffuseLightPipeline: require('./ForwardDiffuseLightPipeline'), ForwardDiffuseLightPipeline: require('./ForwardDiffuseLightPipeline'),
QuadShaderPipeline: require('./QuadShaderPipeline'),
TextureTintPipeline: require('./TextureTintPipeline'), TextureTintPipeline: require('./TextureTintPipeline'),
ModelViewProjection: require('./components/ModelViewProjection') ModelViewProjection: require('./components/ModelViewProjection')

View file

@ -1,43 +0,0 @@
module.exports = [
'#define SHADER_NAME PHASER_QUAD_SHADER_FS',
'',
'precision mediump float;',
'',
'uniform float time;',
'uniform vec2 resolution;',
'uniform vec2 mouse;',
'',
'varying vec2 fragCoord;',
'',
'vec3 hsv2rgb (vec3 c)',
'{',
' vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);',
' vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);',
' return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);',
'}',
'',
'void main (void)',
'{',
' // Normalized pixel coordinates (from 0 to 1)',
' // vec2 uv = fragCoord / resolution.xy;',
'',
' // Time varying pixel color',
' // vec3 col = 0.5 + 0.5 * cos(time + uv.xyx + vec3(0,2,4));',
'',
' // gl_FragColor = vec4(col, 1.0);',
'',
' // vec2 gg = gl_FragCoord.xy;',
' vec2 gg = fragCoord.xy;',
' float bins = 10.0;',
' vec2 pos = (gg / resolution.xy);',
'',
' // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_FragCoord.xhtml',
'',
' // vec2 pos = vec2(resolution.x / gl_FragCoord.x, resolution.y / gl_FragCoord.y);',
'',
' float bin = floor(pos.x * bins);',
'',
' gl_FragColor = vec4(hsv2rgb(vec3(bin/bins, 0.5, 1.0)), 1.0);',
'}',
''
].join('\n');

View file

@ -1,23 +0,0 @@
module.exports = [
'#define SHADER_NAME PHASER_QUAD_SHADER_VS',
'',
'precision mediump float;',
'',
'// These are set in ModelViewProjection.mvpUpdate',
'uniform mat4 uProjectionMatrix;',
'uniform mat4 uViewMatrix;',
'uniform mat4 uModelMatrix;',
'',
'// These are set in QuadShaderPipeline',
'attribute vec2 inPosition;',
'',
'varying vec2 fragCoord;',
'',
'void main ()',
'{',
' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);',
'',
' fragCoord = inPosition;',
'}',
''
].join('\n');

View file

@ -1,40 +0,0 @@
#define SHADER_NAME PHASER_QUAD_SHADER_FS
precision mediump float;
uniform float time;
uniform vec2 resolution;
uniform vec2 mouse;
varying vec2 fragCoord;
vec3 hsv2rgb (vec3 c)
{
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}
void main (void)
{
// Normalized pixel coordinates (from 0 to 1)
// vec2 uv = fragCoord / resolution.xy;
// Time varying pixel color
// vec3 col = 0.5 + 0.5 * cos(time + uv.xyx + vec3(0,2,4));
// gl_FragColor = vec4(col, 1.0);
// vec2 gg = gl_FragCoord.xy;
vec2 gg = fragCoord.xy;
float bins = 10.0;
vec2 pos = (gg / resolution.xy);
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_FragCoord.xhtml
// vec2 pos = vec2(resolution.x / gl_FragCoord.x, resolution.y / gl_FragCoord.y);
float bin = floor(pos.x * bins);
gl_FragColor = vec4(hsv2rgb(vec3(bin/bins, 0.5, 1.0)), 1.0);
}

View file

@ -1,20 +0,0 @@
#define SHADER_NAME PHASER_QUAD_SHADER_VS
precision mediump float;
// These are set in ModelViewProjection.mvpUpdate
uniform mat4 uProjectionMatrix;
uniform mat4 uViewMatrix;
uniform mat4 uModelMatrix;
// These are set in QuadShaderPipeline
attribute vec2 inPosition;
varying vec2 fragCoord;
void main ()
{
gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);
fragCoord = inPosition;
}