diff --git a/src/renderer/webgl/pipelines/FlatTintPipeline.js b/src/renderer/webgl/pipelines/FlatTintPipeline.js index fd47893f4..2a3fc6f4e 100644 --- a/src/renderer/webgl/pipelines/FlatTintPipeline.js +++ b/src/renderer/webgl/pipelines/FlatTintPipeline.js @@ -2,7 +2,8 @@ var Class = require('../../../utils/Class'); var WebGLPipeline = require('../WebGLPipeline'); var Utils = require('../Utils'); var Earcut = require('../../../geom/polygon/Earcut'); -var ShaderSource = require('../shaders/FlatTintShader'); +var ShaderSourceVS = require('../shaders/FlatTint.vert'); +var ShaderSourceFS = require('../shaders/FlatTint.frag'); var FlatTintPipeline = new Class({ @@ -18,8 +19,8 @@ var FlatTintPipeline = new Class({ gl: gl, renderer: renderer, topology: gl.TRIANGLES, - vertShader: ShaderSource.vert, - fragShader: ShaderSource.frag, + vertShader: ShaderSourceVS, + fragShader: ShaderSourceFS, vertexCapacity: 12000, vertexSize: diff --git a/src/renderer/webgl/pipelines/TextureTintPipeline.js b/src/renderer/webgl/pipelines/TextureTintPipeline.js index b97cd6020..50be5cea8 100644 --- a/src/renderer/webgl/pipelines/TextureTintPipeline.js +++ b/src/renderer/webgl/pipelines/TextureTintPipeline.js @@ -1,7 +1,8 @@ var Class = require('../../../utils/Class'); -var ShaderSource = require('../shaders/TextureTintShader'); var WebGLPipeline = require('../WebGLPipeline'); var Utils = require('../Utils'); +var ShaderSourceVS = require('../shaders/TextureTint.vert'); +var ShaderSourceFS = require('../shaders/TextureTint.frag'); var TextureTintPipeline = new Class({ @@ -17,8 +18,8 @@ var TextureTintPipeline = new Class({ gl: gl, renderer: renderer, topology: gl.TRIANGLES, - vertShader: ShaderSource.vert, - fragShader: ShaderSource.frag, + vertShader: ShaderSourceVS, + fragShader: ShaderSourceFS, vertexCapacity: 12000, vertexSize: diff --git a/src/renderer/webgl/shaders/FlatTint.frag b/src/renderer/webgl/shaders/FlatTint.frag index 493e0d063..103d9a503 100644 --- a/src/renderer/webgl/shaders/FlatTint.frag +++ b/src/renderer/webgl/shaders/FlatTint.frag @@ -5,5 +5,5 @@ precision mediump float; varying vec4 outTint; void main() { - gl_FragColor = vec4(outTint.bgr * outTint.a, outTint.a); + gl_FragColor = vec4(outTint.bgr * outTint.a, outTint.a); } diff --git a/src/renderer/webgl/shaders/FlatTint.vert b/src/renderer/webgl/shaders/FlatTint.vert index 9322d4840..44ef8f0a4 100644 --- a/src/renderer/webgl/shaders/FlatTint.vert +++ b/src/renderer/webgl/shaders/FlatTint.vert @@ -10,6 +10,6 @@ attribute vec4 inTint; varying vec4 outTint; void main () { - gl_Position = uOrthoMatrix * vec4(inPosition, 1.0, 1.0); - outTint = inTint; + gl_Position = uOrthoMatrix * vec4(inPosition, 1.0, 1.0); + outTint = inTint; } diff --git a/src/renderer/webgl/shaders/FlatTintShader.js b/src/renderer/webgl/shaders/FlatTintShader.js deleted file mode 100644 index d47c04a35..000000000 --- a/src/renderer/webgl/shaders/FlatTintShader.js +++ /dev/null @@ -1,32 +0,0 @@ -module.exports = { - vert: [ - '#define SHADER_NAME PHASER_FLAT_TINT_VS', - - 'precision mediump float;', - - 'uniform mat4 uOrthoMatrix;', - - 'attribute vec2 inPosition;', - 'attribute vec4 inTint;', - - 'varying vec4 outTint;', - - 'void main () {', - ' gl_Position = uOrthoMatrix * vec4(inPosition, 1.0, 1.0);', - ' outTint = inTint;', - '}' - - ].join('\n'), - frag: [ - '#define SHADER_NAME PHASER_FLAT_TINT_FS', - - 'precision mediump float;', - - 'varying vec4 outTint;', - - 'void main() {', - ' gl_FragColor = vec4(outTint.bgr * outTint.a, outTint.a);', - '}' - - ].join('\n') -}; diff --git a/src/renderer/webgl/shaders/TextureTint.frag b/src/renderer/webgl/shaders/TextureTint.frag new file mode 100644 index 000000000..4078308a1 --- /dev/null +++ b/src/renderer/webgl/shaders/TextureTint.frag @@ -0,0 +1,15 @@ +#define SHADER_NAME PHASER_TEXTURE_TINT_FS + +precision mediump float; + +uniform sampler2D uMainSampler; + +varying vec2 outTexCoord; +varying vec4 outTint; + +void main() +{ + vec4 texel = texture2D(uMainSampler, outTexCoord); + texel *= vec4(outTint.rgb * outTint.a, outTint.a); + gl_FragColor = texel; +} diff --git a/src/renderer/webgl/shaders/TextureTint.vert b/src/renderer/webgl/shaders/TextureTint.vert new file mode 100644 index 000000000..f2d6ea7da --- /dev/null +++ b/src/renderer/webgl/shaders/TextureTint.vert @@ -0,0 +1,20 @@ +#define SHADER_NAME PHASER_TEXTURE_TINT_VS + +precision mediump float; + +uniform mat4 uOrthoMatrix; + +attribute vec2 inPosition; +attribute vec2 inTexCoord; +attribute vec4 inTint; + +varying vec2 outTexCoord; +varying vec4 outTint; + +void main () +{ + gl_Position = uOrthoMatrix * vec4(inPosition, 1.0, 1.0); + outTexCoord = inTexCoord; + outTint = inTint; +} + diff --git a/src/renderer/webgl/shaders/TextureTintShader.js b/src/renderer/webgl/shaders/TextureTintShader.js deleted file mode 100644 index 485192fba..000000000 --- a/src/renderer/webgl/shaders/TextureTintShader.js +++ /dev/null @@ -1,40 +0,0 @@ -module.exports = { - vert: [ - '#define SHADER_NAME PHASER_TEXTURE_TINT_VS', - - 'precision mediump float;', - - 'uniform mat4 uOrthoMatrix;', - - 'attribute vec2 inPosition;', - 'attribute vec2 inTexCoord;', - 'attribute vec4 inTint;', - - 'varying vec2 outTexCoord;', - 'varying vec4 outTint;', - - 'void main () {', - ' gl_Position = uOrthoMatrix * vec4(inPosition, 1.0, 1.0);', - ' outTexCoord = inTexCoord;', - ' outTint = inTint;', - '}' - - ].join('\n'), - frag: [ - '#define SHADER_NAME PHASER_TEXTURE_TINT_FS', - - 'precision mediump float;', - - 'uniform sampler2D uMainSampler;', - - 'varying vec2 outTexCoord;', - 'varying vec4 outTint;', - - 'void main() {', - ' vec4 texel = texture2D(uMainSampler, outTexCoord);', - ' texel *= vec4(outTint.rgb * outTint.a, outTint.a);', - ' gl_FragColor = texel;', - '}' - - ].join('\n') -};