mirror of
https://github.com/photonstorm/phaser
synced 2024-12-17 08:33:40 +00:00
Moved shader source to text files
This commit is contained in:
parent
aec93871c7
commit
6153a34103
8 changed files with 46 additions and 81 deletions
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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')
|
||||
};
|
15
src/renderer/webgl/shaders/TextureTint.frag
Normal file
15
src/renderer/webgl/shaders/TextureTint.frag
Normal 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;
|
||||
}
|
20
src/renderer/webgl/shaders/TextureTint.vert
Normal file
20
src/renderer/webgl/shaders/TextureTint.vert
Normal 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;
|
||||
}
|
||||
|
|
@ -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')
|
||||
};
|
Loading…
Reference in a new issue