Skip to content

Commit 6435772

Browse files
committed
Shaders renamed to match new pipeline names
1 parent 96072e5 commit 6435772

11 files changed

Lines changed: 131 additions & 6 deletions

File tree

scripts/bundle-shaders.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ let fs = require('fs-extra');
33
/*
44
BitmapMask.frag
55
BitmapMask.vert
6-
DeferredDiffuse.frag
7-
DeferredDiffuse.vert
8-
ForwardDiffuse.frag
9-
GBuffer.frag
10-
TextureTint.frag
11-
TextureTint.vert
6+
Light.frag
7+
Single.frag
8+
Single.vert
9+
Multi.frag
10+
Multi.vert
1211
*/
1312

1413
let srcdir = './src/renderer/webgl/shaders/src/';
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
module.exports = [
2+
'#define SHADER_NAME PHASER_SINGLE_TEXTURE_TINT_FS',
3+
'',
4+
'precision mediump float;',
5+
'',
6+
'uniform sampler2D uMainSampler;',
7+
'',
8+
'varying vec2 outTexCoord;',
9+
'varying float outTintEffect;',
10+
'varying vec4 outTint;',
11+
'',
12+
'void main()',
13+
'{',
14+
' vec4 texture = texture2D(uMainSampler, outTexCoord);',
15+
' vec4 texel = vec4(outTint.rgb * outTint.a, outTint.a);',
16+
' vec4 color = texture;',
17+
'',
18+
' if (outTintEffect == 0.0)',
19+
' {',
20+
' // Multiply texture tint',
21+
' color = texture * texel;',
22+
' }',
23+
' else if (outTintEffect == 1.0)',
24+
' {',
25+
' // Solid color + texture alpha',
26+
' color.rgb = mix(texture.rgb, outTint.rgb * outTint.a, texture.a);',
27+
' color.a = texture.a * texel.a;',
28+
' }',
29+
' else if (outTintEffect == 2.0)',
30+
' {',
31+
' // Solid color, no texture',
32+
' color = texel;',
33+
' }',
34+
'',
35+
' gl_FragColor = color;',
36+
'}',
37+
''
38+
].join('\n');
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = [
2+
'#define SHADER_NAME PHASER_SINGLE_TEXTURE_TINT_VS',
3+
'',
4+
'precision mediump float;',
5+
'',
6+
'uniform mat4 uProjectionMatrix;',
7+
'uniform mat4 uViewMatrix;',
8+
'uniform mat4 uModelMatrix;',
9+
'',
10+
'attribute vec2 inPosition;',
11+
'attribute vec2 inTexCoord;',
12+
'attribute float inTintEffect;',
13+
'attribute vec4 inTint;',
14+
'',
15+
'varying vec2 outTexCoord;',
16+
'varying float outTintEffect;',
17+
'varying vec4 outTint;',
18+
'',
19+
'void main ()',
20+
'{',
21+
' gl_Position = uProjectionMatrix * uViewMatrix * uModelMatrix * vec4(inPosition, 1.0, 1.0);',
22+
'',
23+
' outTexCoord = inTexCoord;',
24+
' outTint = inTint;',
25+
' outTintEffect = inTintEffect;',
26+
'}',
27+
''
28+
].join('\n');
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#define SHADER_NAME PHASER_SINGLE_TEXTURE_TINT_FS
2+
3+
precision mediump float;
4+
5+
uniform sampler2D uMainSampler;
6+
7+
varying vec2 outTexCoord;
8+
varying float outTintEffect;
9+
varying vec4 outTint;
10+
11+
void main()
12+
{
13+
vec4 texture = texture2D(uMainSampler, outTexCoord);
14+
vec4 texel = vec4(outTint.rgb * outTint.a, outTint.a);
15+
vec4 color = texture;
16+
17+
if (outTintEffect == 0.0)
18+
{
19+
// Multiply texture tint
20+
color = texture * texel;
21+
}
22+
else if (outTintEffect == 1.0)
23+
{
24+
// Solid color + texture alpha
25+
color.rgb = mix(texture.rgb, outTint.rgb * outTint.a, texture.a);
26+
color.a = texture.a * texel.a;
27+
}
28+
else if (outTintEffect == 2.0)
29+
{
30+
// Solid color, no texture
31+
color = texel;
32+
}
33+
34+
gl_FragColor = color;
35+
}

0 commit comments

Comments
 (0)