Skip to content

Commit 00a9897

Browse files
committed
Updated Filter resolution to a 2f and added Blur and Marble filters.
1 parent 378ffc7 commit 00a9897

17 files changed

Lines changed: 219 additions & 77 deletions

File tree

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Phaser 1.1
55

66
Phaser is a fast, free and fun open source game framework for making desktop and mobile browser HTML5 games. It uses [Pixi.js](https://github.com/GoodBoyDigital/pixi.js/) internally for fast 2D Canvas and WebGL rendering.
77

8-
Version: 1.1.3 - Released: November 28th 2013
8+
Version: 1.1.3 - Released: November 29th 2013
99

1010
By Richard Davey, [Photon Storm](http://www.photonstorm.com)
1111

@@ -39,7 +39,7 @@ Phaser is everything we ever wanted from an HTML5 game framework. It powers all
3939
Change Log
4040
----------
4141

42-
Version 1.1.3 - November 28th 2013
42+
Version 1.1.3 - November 29th 2013
4343

4444
* New: Added a .jshintrc so contributions can be run through JSHint to help retain formatting across the library (thanks kevinthompson)
4545
* New: The entire Phaser library has been updated to match the new JSHint configuration.
@@ -228,7 +228,7 @@ Using a locally installed web server browse to the examples folder:
228228

229229
examples/index.html
230230

231-
Alternatively in order to start the included web server, after you've cloned the repo, run npm install to install all dependencies, then run grunt connect to start a local server. After running this command, you should be able to access your local webserver at `http://127.0.0.1:8000`. Then browse to the examples folder: `http://127.0.0.1:8000/examples/index.html`
231+
Alternatively in order to start the included web server, after you've cloned the repo, run `npm install` to install all dependencies, then `grunt connect `to start a local server. After running this command you should be able to access your local webserver at `http://127.0.0.1:8000`. Then browse to the examples folder: `http://127.0.0.1:8000/examples/index.html`
232232

233233
There is a new 'Side View' example viewer as well. This loads all the examples into a left-hand frame for faster navigation.
234234

@@ -237,8 +237,6 @@ You can also browse all [Phaser Examples](http://gametest.mobi/phaser/) online.
237237
Contributing
238238
------------
239239

240-
Phaser is in early stages and although we've still got a lot to add to it, we wanted to get it out there and share it with the world.
241-
242240
If you find a bug (highly likely!) then please report it on github or our forum.
243241

244242
If you have a feature request, or have written a small game or demo that shows Phaser in use, then please get in touch. We'd love to hear from you.

examples/_site/examples.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@
178178
}
179179
],
180180
"filters": [
181+
{
182+
"file": "blur.js",
183+
"title": "blur"
184+
},
181185
{
182186
"file": "checker+wave.js",
183187
"title": "checker wave"
@@ -186,10 +190,6 @@
186190
"file": "fire.js",
187191
"title": "fire"
188192
},
189-
{
190-
"file": "hue+rotate.js",
191-
"title": "hue rotate"
192-
},
193193
{
194194
"file": "lightbeams.js",
195195
"title": "lightbeams"

examples/filters/blur.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
var game = new Phaser.Game(800, 600, Phaser.WEBGL, 'phaser-example', { preload: preload, create: create });
3+
4+
function preload() {
5+
6+
game.load.image('phaser', 'assets/sprites/phaser2.png');
7+
game.load.script('filterX', '../filters/BlurX.js');
8+
game.load.script('filterY', '../filters/BlurY.js');
9+
10+
}
11+
12+
function create() {
13+
14+
var logo = game.add.sprite(game.world.centerX, game.world.centerY, 'phaser');
15+
logo.anchor.setTo(0.5, 0.5);
16+
17+
var blurX = game.add.filter('BlurX');
18+
var blurY = game.add.filter('BlurY');
19+
20+
logo.filters = [blurX, blurY];
21+
22+
}

examples/filters/hue rotate.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

examples/filters/marble.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ function create() {
2121
background.height = 600;
2222

2323
filter = game.add.filter('Marble', 800, 600);
24-
//filter.alpha = 0.0;
24+
filter.alpha = 0.2;
25+
26+
// The following properties are available (shown at default values)
27+
28+
// filter.speed = 10.0;
29+
// filter.intensity = 0.30;
2530

2631
background.filters = [filter];
2732

filters/BlurX.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* A horizontal blur filter by Mat Groves http://matgroves.com/ @Doormat23
3+
*/
4+
Phaser.Filter.BlurX = function (game) {
5+
6+
Phaser.Filter.call(this, game);
7+
8+
this.uniforms.blur = { type: '1f', value: 1 / 512 };
9+
10+
this.fragmentSrc = [
11+
12+
"precision mediump float;",
13+
"varying vec2 vTextureCoord;",
14+
"varying float vColor;",
15+
"uniform float blur;",
16+
"uniform sampler2D uSampler;",
17+
18+
"void main(void) {",
19+
"vec4 sum = vec4(0.0);",
20+
21+
"sum += texture2D(uSampler, vec2(vTextureCoord.x - 4.0*blur, vTextureCoord.y)) * 0.05;",
22+
"sum += texture2D(uSampler, vec2(vTextureCoord.x - 3.0*blur, vTextureCoord.y)) * 0.09;",
23+
"sum += texture2D(uSampler, vec2(vTextureCoord.x - 2.0*blur, vTextureCoord.y)) * 0.12;",
24+
"sum += texture2D(uSampler, vec2(vTextureCoord.x - blur, vTextureCoord.y)) * 0.15;",
25+
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;",
26+
"sum += texture2D(uSampler, vec2(vTextureCoord.x + blur, vTextureCoord.y)) * 0.15;",
27+
"sum += texture2D(uSampler, vec2(vTextureCoord.x + 2.0*blur, vTextureCoord.y)) * 0.12;",
28+
"sum += texture2D(uSampler, vec2(vTextureCoord.x + 3.0*blur, vTextureCoord.y)) * 0.09;",
29+
"sum += texture2D(uSampler, vec2(vTextureCoord.x + 4.0*blur, vTextureCoord.y)) * 0.05;",
30+
31+
"gl_FragColor = sum;",
32+
33+
"}"
34+
];
35+
36+
};
37+
38+
Phaser.Filter.BlurX.prototype = Object.create(Phaser.Filter.prototype);
39+
Phaser.Filter.BlurX.prototype.constructor = Phaser.Filter.BlurX;
40+
41+
Object.defineProperty(Phaser.Filter.BlurX.prototype, 'blur', {
42+
43+
get: function() {
44+
return this.uniforms.blur.value / (1/7000);
45+
},
46+
47+
set: function(value) {
48+
this.uniforms.blur.value = (1/7000) * value;
49+
}
50+
51+
});

filters/BlurY.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* A vertical blur filter by Mat Groves http://matgroves.com/ @Doormat23
3+
*/
4+
Phaser.Filter.BlurY = function (game) {
5+
6+
Phaser.Filter.call(this, game);
7+
8+
this.uniforms.blur = { type: '1f', value: 1 / 512 };
9+
10+
this.fragmentSrc = [
11+
12+
"precision mediump float;",
13+
"varying vec2 vTextureCoord;",
14+
"varying float vColor;",
15+
"uniform float blur;",
16+
"uniform sampler2D uSampler;",
17+
18+
"void main(void) {",
19+
"vec4 sum = vec4(0.0);",
20+
21+
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 4.0*blur)) * 0.05;",
22+
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 3.0*blur)) * 0.09;",
23+
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 2.0*blur)) * 0.12;",
24+
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - blur)) * 0.15;",
25+
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;",
26+
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + blur)) * 0.15;",
27+
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 2.0*blur)) * 0.12;",
28+
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 3.0*blur)) * 0.09;",
29+
"sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 4.0*blur)) * 0.05;",
30+
31+
"gl_FragColor = sum;",
32+
33+
"}"
34+
35+
];
36+
37+
};
38+
39+
Phaser.Filter.BlurY.prototype = Object.create(Phaser.Filter.prototype);
40+
Phaser.Filter.BlurY.prototype.constructor = Phaser.Filter.BlurY;
41+
42+
Object.defineProperty(Phaser.Filter.BlurY.prototype, 'blur', {
43+
44+
get: function() {
45+
return this.uniforms.blur.value / (1/7000);
46+
},
47+
48+
set: function(value) {
49+
this.uniforms.blur.value = (1/7000) * value;
50+
}
51+
52+
});

filters/CheckerWave.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Phaser.Filter.CheckerWave = function (game) {
1414
this.fragmentSrc = [
1515

1616
"precision mediump float;",
17-
"uniform vec3 resolution;",
17+
"uniform vec2 resolution;",
1818
"uniform float time;",
1919
"uniform float alpha;",
2020
"uniform vec3 vrp;",
@@ -122,7 +122,7 @@ Phaser.Filter.CheckerWave.prototype.setColor2 = function (red, green, blue) {
122122

123123
}
124124

125-
Object.defineProperty(Phaser.Filter.HueRotate.prototype, 'alpha', {
125+
Object.defineProperty(Phaser.Filter.CheckerWave.prototype, 'alpha', {
126126

127127
get: function() {
128128
return this.uniforms.alpha.value;
@@ -134,7 +134,7 @@ Object.defineProperty(Phaser.Filter.HueRotate.prototype, 'alpha', {
134134

135135
});
136136

137-
Object.defineProperty(Phaser.Filter.HueRotate.prototype, 'cameraX', {
137+
Object.defineProperty(Phaser.Filter.CheckerWave.prototype, 'cameraX', {
138138

139139
get: function() {
140140
return this.uniforms.vrp.value.x;
@@ -146,7 +146,7 @@ Object.defineProperty(Phaser.Filter.HueRotate.prototype, 'cameraX', {
146146

147147
});
148148

149-
Object.defineProperty(Phaser.Filter.HueRotate.prototype, 'cameraY', {
149+
Object.defineProperty(Phaser.Filter.CheckerWave.prototype, 'cameraY', {
150150

151151
get: function() {
152152
return this.uniforms.vrp.value.y;
@@ -158,7 +158,7 @@ Object.defineProperty(Phaser.Filter.HueRotate.prototype, 'cameraY', {
158158

159159
});
160160

161-
Object.defineProperty(Phaser.Filter.HueRotate.prototype, 'cameraZ', {
161+
Object.defineProperty(Phaser.Filter.CheckerWave.prototype, 'cameraZ', {
162162

163163
get: function() {
164164
return this.uniforms.vrp.value.z;

filters/Fire.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Phaser.Filter.Fire = function (game) {
1313
this.fragmentSrc = [
1414

1515
"precision mediump float;",
16-
"uniform vec3 resolution;",
16+
"uniform vec2 resolution;",
1717
"uniform float time;",
1818
"uniform float alpha;",
1919
"uniform vec2 speed;",

filters/HueRotate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Phaser.Filter.HueRotate = function (game) {
1313
this.fragmentSrc = [
1414

1515
"precision mediump float;",
16-
"uniform vec3 resolution;",
16+
"uniform vec2 resolution;",
1717
"uniform float time;",
1818
"uniform float alpha;",
1919
"uniform sampler2D iChannel0;",

0 commit comments

Comments
 (0)