Moved shader source to text files

This commit is contained in:
Felipe Alfonso 2018-01-22 20:01:00 -03:00
parent aec93871c7
commit 6153a34103
8 changed files with 46 additions and 81 deletions

View file

@ -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:

View file

@ -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:

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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')
};

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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')
};