mirror of
https://github.com/photonstorm/phaser
synced 2024-11-16 09:48:18 +00:00
Added new utility shaders
This commit is contained in:
parent
24406d2d4f
commit
d677b57ee4
10 changed files with 179 additions and 0 deletions
20
src/renderer/webgl/shaders/AddBlend-frag.js
Normal file
20
src/renderer/webgl/shaders/AddBlend-frag.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
module.exports = [
|
||||
'#define SHADER_NAME PHASER_ADD_BLEND_FS',
|
||||
'',
|
||||
'precision mediump float;',
|
||||
'',
|
||||
'uniform sampler2D uMainSampler1;',
|
||||
'uniform sampler2D uMainSampler2;',
|
||||
'uniform float uStrength;',
|
||||
'',
|
||||
'varying vec2 outTexCoord;',
|
||||
'',
|
||||
'void main ()',
|
||||
'{',
|
||||
' vec4 frame1 = texture2D(uMainSampler1, outTexCoord);',
|
||||
' vec4 frame2 = texture2D(uMainSampler2, outTexCoord);',
|
||||
'',
|
||||
' gl_FragColor = frame1 + frame2 * uStrength;',
|
||||
'}',
|
||||
''
|
||||
].join('\n');
|
21
src/renderer/webgl/shaders/ColorMatrix-frag.js
Normal file
21
src/renderer/webgl/shaders/ColorMatrix-frag.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
module.exports = [
|
||||
'#define SHADER_NAME PHASER_COLORMATRIX_FS',
|
||||
'',
|
||||
'precision mediump float;',
|
||||
'',
|
||||
'uniform sampler2D uMainSampler;',
|
||||
'uniform float uColorMatrix[20];',
|
||||
'',
|
||||
'varying vec2 outTexCoord;',
|
||||
'',
|
||||
'void main ()',
|
||||
'{',
|
||||
' vec4 c = texture2D(uMainSampler, outTexCoord);',
|
||||
'',
|
||||
' gl_FragColor.r = uColorMatrix[0] * c.r + uColorMatrix[1] * c.g + uColorMatrix[2] * c.b + uColorMatrix[4];',
|
||||
' gl_FragColor.g = uColorMatrix[5] * c.r + uColorMatrix[6] * c.g + uColorMatrix[7] * c.b + uColorMatrix[9];',
|
||||
' gl_FragColor.b = uColorMatrix[10] * c.r + uColorMatrix[11] * c.g + uColorMatrix[12] * c.b + uColorMatrix[14];',
|
||||
' gl_FragColor.a = c.a;',
|
||||
'}',
|
||||
''
|
||||
].join('\n');
|
16
src/renderer/webgl/shaders/Copy-frag.js
Normal file
16
src/renderer/webgl/shaders/Copy-frag.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
module.exports = [
|
||||
'#define SHADER_NAME PHASER_COPY_FS',
|
||||
'',
|
||||
'precision mediump float;',
|
||||
'',
|
||||
'uniform sampler2D uMainSampler;',
|
||||
'uniform float uBrightness;',
|
||||
'',
|
||||
'varying vec2 outTexCoord;',
|
||||
'',
|
||||
'void main()',
|
||||
'{',
|
||||
' gl_FragColor = texture2D(uMainSampler, outTexCoord) * uBrightness;',
|
||||
'}',
|
||||
''
|
||||
].join('\n');
|
20
src/renderer/webgl/shaders/LinearBlend-frag.js
Normal file
20
src/renderer/webgl/shaders/LinearBlend-frag.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
module.exports = [
|
||||
'#define SHADER_NAME PHASER_LINEAR_BLEND_FS',
|
||||
'',
|
||||
'precision mediump float;',
|
||||
'',
|
||||
'uniform sampler2D uMainSampler1;',
|
||||
'uniform sampler2D uMainSampler2;',
|
||||
'uniform float uStrength;',
|
||||
'',
|
||||
'varying vec2 outTexCoord;',
|
||||
'',
|
||||
'void main ()',
|
||||
'{',
|
||||
' vec4 frame1 = texture2D(uMainSampler1, outTexCoord);',
|
||||
' vec4 frame2 = texture2D(uMainSampler2, outTexCoord);',
|
||||
'',
|
||||
' gl_FragColor = mix(frame1, frame2 * uStrength, 0.5);',
|
||||
'}',
|
||||
''
|
||||
].join('\n');
|
20
src/renderer/webgl/shaders/Quad-vert.js
Normal file
20
src/renderer/webgl/shaders/Quad-vert.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
module.exports = [
|
||||
'#define SHADER_NAME PHASER_QUAD_VS',
|
||||
'',
|
||||
'precision mediump float;',
|
||||
'',
|
||||
'uniform mat4 uProjectionMatrix;',
|
||||
'',
|
||||
'attribute vec2 inPosition;',
|
||||
'attribute vec2 inTexCoord;',
|
||||
'',
|
||||
'varying vec2 outTexCoord;',
|
||||
'',
|
||||
'void main ()',
|
||||
'{',
|
||||
' gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);',
|
||||
'',
|
||||
' outTexCoord = gl_Position.xy * 0.5 + 0.5;',
|
||||
'}',
|
||||
''
|
||||
].join('\n');
|
17
src/renderer/webgl/shaders/src/AddBlend.frag
Normal file
17
src/renderer/webgl/shaders/src/AddBlend.frag
Normal file
|
@ -0,0 +1,17 @@
|
|||
#define SHADER_NAME PHASER_ADD_BLEND_FS
|
||||
|
||||
precision mediump float;
|
||||
|
||||
uniform sampler2D uMainSampler1;
|
||||
uniform sampler2D uMainSampler2;
|
||||
uniform float uStrength;
|
||||
|
||||
varying vec2 outTexCoord;
|
||||
|
||||
void main ()
|
||||
{
|
||||
vec4 frame1 = texture2D(uMainSampler1, outTexCoord);
|
||||
vec4 frame2 = texture2D(uMainSampler2, outTexCoord);
|
||||
|
||||
gl_FragColor = frame1 + frame2 * uStrength;
|
||||
}
|
18
src/renderer/webgl/shaders/src/ColorMatrix.frag
Normal file
18
src/renderer/webgl/shaders/src/ColorMatrix.frag
Normal file
|
@ -0,0 +1,18 @@
|
|||
#define SHADER_NAME PHASER_COLORMATRIX_FS
|
||||
|
||||
precision mediump float;
|
||||
|
||||
uniform sampler2D uMainSampler;
|
||||
uniform float uColorMatrix[20];
|
||||
|
||||
varying vec2 outTexCoord;
|
||||
|
||||
void main ()
|
||||
{
|
||||
vec4 c = texture2D(uMainSampler, outTexCoord);
|
||||
|
||||
gl_FragColor.r = uColorMatrix[0] * c.r + uColorMatrix[1] * c.g + uColorMatrix[2] * c.b + uColorMatrix[4];
|
||||
gl_FragColor.g = uColorMatrix[5] * c.r + uColorMatrix[6] * c.g + uColorMatrix[7] * c.b + uColorMatrix[9];
|
||||
gl_FragColor.b = uColorMatrix[10] * c.r + uColorMatrix[11] * c.g + uColorMatrix[12] * c.b + uColorMatrix[14];
|
||||
gl_FragColor.a = c.a;
|
||||
}
|
13
src/renderer/webgl/shaders/src/Copy.frag
Normal file
13
src/renderer/webgl/shaders/src/Copy.frag
Normal file
|
@ -0,0 +1,13 @@
|
|||
#define SHADER_NAME PHASER_COPY_FS
|
||||
|
||||
precision mediump float;
|
||||
|
||||
uniform sampler2D uMainSampler;
|
||||
uniform float uBrightness;
|
||||
|
||||
varying vec2 outTexCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = texture2D(uMainSampler, outTexCoord) * uBrightness;
|
||||
}
|
17
src/renderer/webgl/shaders/src/LinearBlend.frag
Normal file
17
src/renderer/webgl/shaders/src/LinearBlend.frag
Normal file
|
@ -0,0 +1,17 @@
|
|||
#define SHADER_NAME PHASER_LINEAR_BLEND_FS
|
||||
|
||||
precision mediump float;
|
||||
|
||||
uniform sampler2D uMainSampler1;
|
||||
uniform sampler2D uMainSampler2;
|
||||
uniform float uStrength;
|
||||
|
||||
varying vec2 outTexCoord;
|
||||
|
||||
void main ()
|
||||
{
|
||||
vec4 frame1 = texture2D(uMainSampler1, outTexCoord);
|
||||
vec4 frame2 = texture2D(uMainSampler2, outTexCoord);
|
||||
|
||||
gl_FragColor = mix(frame1, frame2 * uStrength, 0.5);
|
||||
}
|
17
src/renderer/webgl/shaders/src/Quad.vert
Normal file
17
src/renderer/webgl/shaders/src/Quad.vert
Normal file
|
@ -0,0 +1,17 @@
|
|||
#define SHADER_NAME PHASER_QUAD_VS
|
||||
|
||||
precision mediump float;
|
||||
|
||||
uniform mat4 uProjectionMatrix;
|
||||
|
||||
attribute vec2 inPosition;
|
||||
attribute vec2 inTexCoord;
|
||||
|
||||
varying vec2 outTexCoord;
|
||||
|
||||
void main ()
|
||||
{
|
||||
gl_Position = uProjectionMatrix * vec4(inPosition, 1.0, 1.0);
|
||||
|
||||
outTexCoord = gl_Position.xy * 0.5 + 0.5;
|
||||
}
|
Loading…
Reference in a new issue