mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 14:08:28 +00:00
Custom phaser shaders
This commit is contained in:
parent
25dfe24e4d
commit
49272eb9c3
4 changed files with 80 additions and 4 deletions
|
@ -7,8 +7,8 @@
|
|||
var CONST = require('../const');
|
||||
var CanvasPool = require('../dom/CanvasPool');
|
||||
var Features = require('../device/Features');
|
||||
var CanvasRenderer = require('../renderer/canvas/CanvasRenderer');
|
||||
var WebGLRenderer = require('../renderer/webgl/WebGLRenderer');
|
||||
//var CanvasRenderer = require('../renderer/canvas/CanvasRenderer');
|
||||
//var WebGLRenderer = require('../renderer/webgl/WebGLRenderer');
|
||||
var CanvasInterpolation = require('../dom/CanvasInterpolation');
|
||||
|
||||
/**
|
||||
|
@ -71,7 +71,7 @@ var CreateRenderer = function (game)
|
|||
}
|
||||
|
||||
// Create the renderer
|
||||
if (config.renderType === CONST.WEBGL)
|
||||
/*if (config.renderType === CONST.WEBGL)
|
||||
{
|
||||
game.renderer = new WebGLRenderer(game);
|
||||
game.context = null;
|
||||
|
@ -83,7 +83,7 @@ var CreateRenderer = function (game)
|
|||
|
||||
// debug
|
||||
game.canvas.id = 'game';
|
||||
}
|
||||
}*/
|
||||
};
|
||||
|
||||
module.exports = CreateRenderer;
|
||||
|
|
24
v3/src/renderer/webgl/shaders/TexturedAndAlphaShader.js
Normal file
24
v3/src/renderer/webgl/shaders/TexturedAndAlphaShader.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
module.exports = {
|
||||
vert: [
|
||||
'uniform mat4 u_view_matrix;',
|
||||
'attribute vec2 a_position;',
|
||||
'attribute vec2 a_tex_coord;',
|
||||
'attribute float a_alpha;',
|
||||
'varying vec2 v_tex_coord;',
|
||||
'varying float v_alpha;',
|
||||
'void main () {',
|
||||
' gl_Position = u_view_matrix * vec4(a_position, 1.0, 1.0);',
|
||||
' v_tex_coord = a_tex_coord;',
|
||||
' v_alpha = a_alpha;',
|
||||
'}'
|
||||
].join('\n'),
|
||||
frag: [
|
||||
'precision mediump float;',
|
||||
'uniform sampler2D u_sampler2D;',
|
||||
'varying vec2 v_tex_coord;',
|
||||
'varying float v_alpha;',
|
||||
'void main() {',
|
||||
' gl_FragColor = texture2D(u_sampler2D, v_tex_coord) * vec4(1.0, 1.0, 1.0, v_alpha);',
|
||||
'}'
|
||||
].join('\n')
|
||||
};
|
28
v3/src/renderer/webgl/shaders/TexturedAndTintedShader.js
Normal file
28
v3/src/renderer/webgl/shaders/TexturedAndTintedShader.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
module.exports = {
|
||||
vert: [
|
||||
'uniform mat4 u_view_matrix;',
|
||||
'attribute vec2 a_position;',
|
||||
'attribute vec2 a_tex_coord;',
|
||||
'attribute vec3 a_color;',
|
||||
'attribute float a_alpha;',
|
||||
'varying vec2 v_tex_coord;',
|
||||
'varying vec3 v_color;',
|
||||
'varying float v_alpha;',
|
||||
'void main () {',
|
||||
' gl_Position = u_view_matrix * vec4(a_position, 1.0, 1.0);',
|
||||
' v_tex_coord = a_tex_coord;',
|
||||
' v_color = a_color;',
|
||||
' v_alpha = a_alpha;',
|
||||
'}'
|
||||
].join('\n'),
|
||||
frag: [
|
||||
'precision mediump float;',
|
||||
'uniform sampler2D u_sampler2D;',
|
||||
'varying vec2 v_tex_coord;',
|
||||
'varying vec3 v_color;',
|
||||
'varying float v_alpha;',
|
||||
'void main() {',
|
||||
' gl_FragColor = texture2D(u_sampler2D, v_tex_coord) * vec4(v_color, v_alpha);',
|
||||
'}'
|
||||
].join('\n')
|
||||
};
|
24
v3/src/renderer/webgl/shaders/UntexturedAndTintedShader.js
Normal file
24
v3/src/renderer/webgl/shaders/UntexturedAndTintedShader.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
module.exports = {
|
||||
vert: [
|
||||
'precision mediump float;',
|
||||
'uniform mat4 u_view_matrix;',
|
||||
'attribute vec2 a_position;',
|
||||
'attribute vec4 a_color;',
|
||||
'attribute float a_alpha;',
|
||||
'varying vec4 v_color;',
|
||||
'varying float v_alpha;',
|
||||
'void main () {',
|
||||
' gl_Position = u_view_matrix * vec4(a_position, 1.0, 1.0);',
|
||||
' v_color = a_color;',
|
||||
' v_alpha = a_alpha;',
|
||||
'}'
|
||||
].join('\n'),
|
||||
frag: [
|
||||
'precision mediump float;',
|
||||
'varying vec4 v_color;',
|
||||
'varying float v_alpha;',
|
||||
'void main() {',
|
||||
' gl_FragColor = vec4(v_color.bgr, v_alpha);',
|
||||
'}'
|
||||
].join('\n')
|
||||
};
|
Loading…
Add table
Reference in a new issue