diff --git a/build/config.php b/build/config.php index 04991d46..1f0b68e7 100644 --- a/build/config.php +++ b/build/config.php @@ -28,7 +28,9 @@ + + diff --git a/examples/_site/examples.json b/examples/_site/examples.json index 8314749f..dd36c136 100644 --- a/examples/_site/examples.json +++ b/examples/_site/examples.json @@ -178,10 +178,18 @@ } ], "filters": [ + { + "file": "checker+wave.js", + "title": "checker wave" + }, { "file": "fire.js", "title": "fire" }, + { + "file": "hue+rotate.js", + "title": "hue rotate" + }, { "file": "lightbeams.js", "title": "lightbeams" diff --git a/examples/_site/js/phaser-examples.js b/examples/_site/js/phaser-examples.js index 3b9260f4..51c7587a 100644 --- a/examples/_site/js/phaser-examples.js +++ b/examples/_site/js/phaser-examples.js @@ -95,8 +95,6 @@ $(document).ready(function(){ .done(function(data) { - console.log(data); - if (data.version !== '1.1.3') { $("#upgrade").append(data.version); diff --git a/examples/_site/js/phaser-viewer.js b/examples/_site/js/phaser-viewer.js index 80fd3a49..6b154048 100644 --- a/examples/_site/js/phaser-viewer.js +++ b/examples/_site/js/phaser-viewer.js @@ -58,8 +58,6 @@ $(document).ready(function(){ .done(function(data) { - console.log(data); - if (data.version !== '1.1.3') { $("#upgrade").append(data.version); diff --git a/examples/filters/checker wave.js b/examples/filters/checker wave.js new file mode 100644 index 00000000..a8bdc13e --- /dev/null +++ b/examples/filters/checker wave.js @@ -0,0 +1,37 @@ + +var game = new Phaser.Game(800, 600, Phaser.WEBGL, 'phaser-example', { preload: preload, create: create, update: update }); + +var background; +var filter; + +function preload() { + + game.load.image('s', 'assets/pics/undersea.jpg'); + game.load.image('phaser', 'assets/sprites/phaser.png'); + game.load.script('filter', '../filters/CheckerWave.js'); + +} + +function create() { + + game.add.sprite(0, 0, 's'); + + background = game.add.sprite(0, 0); + background.width = 800; + background.height = 600; + + filter = game.add.filter('CheckerWave', 800, 600); + filter.alpha = 0.2; + + background.filters = [filter]; + + var logo = game.add.sprite(game.world.centerX, 100, 'phaser'); + logo.anchor.setTo(0.5, 0.5); + +} + +function update() { + + filter.update(); + +} diff --git a/examples/filters/fire.js b/examples/filters/fire.js index 7208df53..d4c1bf60 100644 --- a/examples/filters/fire.js +++ b/examples/filters/fire.js @@ -7,7 +7,7 @@ var filter; function preload() { game.load.image('phaser', 'assets/sprites/phaser2.png'); - game.load.script('fire', '../filters/Fire.js'); + game.load.script('filter', '../filters/Fire.js'); } diff --git a/examples/filters/hue rotate.js b/examples/filters/hue rotate.js new file mode 100644 index 00000000..b435dfcd --- /dev/null +++ b/examples/filters/hue rotate.js @@ -0,0 +1,38 @@ + +var game = new Phaser.Game(800, 600, Phaser.WEBGL, 'phaser-example', { preload: preload, create: create, update: update }); + +var background; +var filter; + +function preload() { + + game.load.image('phaser', 'assets/sprites/phaser2.png'); + game.load.script('filter', '../filters/HueRotate.js'); + // game.load.image('texture', 'assets/textures/ooze.png'); + game.load.image('texture', 'assets/pics/ra_einstein.png'); + +} + +function create() { + + var logo = game.add.sprite(game.world.centerX, game.world.centerY, 'texture'); + logo.anchor.setTo(0.5, 0.5); + logo.texture.baseTexture._powerOf2 = true; + + + background = game.add.sprite(0, 0); + background.width = logo.width; + background.height = logo.height; + + filter = game.add.filter('HueRotate', logo.width, logo.height, logo.texture); + // filter.alpha = 0.0; + + background.filters = [filter]; + +} + +function update() { + + filter.update(); + +} diff --git a/examples/filters/lightbeams.js b/examples/filters/lightbeams.js index 3802670f..ff8d7ca8 100644 --- a/examples/filters/lightbeams.js +++ b/examples/filters/lightbeams.js @@ -7,7 +7,7 @@ var filter; function preload() { game.load.image('phaser', 'assets/sprites/phaser2.png'); - game.load.script('light', '../filters/LightBeam.js'); + game.load.script('filter', '../filters/LightBeam.js'); } diff --git a/examples/filters/plasma.js b/examples/filters/plasma.js index 90d59f32..747a0880 100644 --- a/examples/filters/plasma.js +++ b/examples/filters/plasma.js @@ -7,7 +7,7 @@ var filter; function preload() { game.load.image('phaser', 'assets/sprites/phaser2.png'); - game.load.script('plasma', '../filters/Plasma.js'); + game.load.script('filter', '../filters/Plasma.js'); } diff --git a/examples/filters/tunnel.js b/examples/filters/tunnel.js index 42314d62..2b875b59 100644 --- a/examples/filters/tunnel.js +++ b/examples/filters/tunnel.js @@ -8,7 +8,7 @@ function preload() { game.load.image('phaser', 'assets/sprites/phaser.png'); game.load.image('texture', 'assets/textures/ooze.png'); - game.load.script('tunnel', '../filters/Tunnel.js'); + game.load.script('filter', '../filters/Tunnel.js'); } diff --git a/examples/wip/TRSIPlasmaFilter.js b/examples/wip/TRSIPlasmaFilter.js index 3b74be2a..1381cc49 100644 --- a/examples/wip/TRSIPlasmaFilter.js +++ b/examples/wip/TRSIPlasmaFilter.js @@ -14,9 +14,9 @@ PIXI.TRSIPlasmaFilter = function(width, height) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates } }; // Shader by Rebb / TRSI (https://www.shadertoy.com/view/XdX3Wn) diff --git a/examples/wip/book/part2.html b/examples/wip/book/part2.html index 4dc8c78a..8ce054ba 100644 --- a/examples/wip/book/part2.html +++ b/examples/wip/book/part2.html @@ -9,10 +9,8 @@ margin: 0; } - // - diff --git a/examples/wip/c64PlasmaFilter.js b/examples/wip/c64PlasmaFilter.js index 73cd9769..48ceb031 100644 --- a/examples/wip/c64PlasmaFilter.js +++ b/examples/wip/c64PlasmaFilter.js @@ -14,9 +14,9 @@ PIXI.C64PlasmaFilter = function(width, height) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates } }; // Shader by ssdsa (https://www.shadertoy.com/view/MslGzN) diff --git a/examples/wip/caustic lights.js b/examples/wip/caustic lights.js new file mode 100644 index 00000000..bc056836 --- /dev/null +++ b/examples/wip/caustic lights.js @@ -0,0 +1,125 @@ +PIXI.BinarySerpentsFilter = function(width, height, texture) +{ + PIXI.AbstractFilter.call( this ); + + this.passes = [this]; + + var d = new Date(); + + var dates = [ + d.getFullYear(), // the year (four digits) + d.getMonth(), // the month (from 0-11) + d.getDate(), // the day of the month (from 1-31) + d.getHours()*60.0*60 + d.getMinutes()*60 + d.getSeconds() + ]; + + this.uniforms = { + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iMouse: { type: '3f', value: { x: 0, y: 0, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, + iChannel0: { type: 'sampler2D', value: texture, wrap: 'repeat' } + }; + +this.fragmentSrc = [ + "#ifdef GL_ES", + "precision mediump float;", + "#endif", + "//Ashok Gowtham M", + "//UnderWater Caustic lights", + "uniform float time;", + "uniform vec2 mouse;", + "uniform vec2 resolution;", + "//normalized sin", + "float sinn(float x)", + "{", + "return sin(x)/2.+.001;", + "}", + + "float CausticPatternFn(vec2 pos)", + "{", + "return (sin(pos.x*40.+time)", + "+pow(sin(-pos.x*130.+time),1.)", + "+pow(sin(pos.x*30.+time),2.)", + "+pow(sin(pos.x*50.+time),2.)", + "+pow(sin(pos.x*80.+time),2.)", + "+pow(sin(pos.x*90.+time),2.)", + "+pow(sin(pos.x*12.+time),2.)", + "+pow(sin(pos.x*6.+time),2.)", + "+pow(sin(-pos.x*13.+time),5.))/2.;", + "}", + + "vec2 CausticDistortDomainFn(vec2 pos)", + "{", + "pos.x*=(pos.y*0.60+1.);", + "pos.x*=1.+sin(time/2.)/10.;", + "return pos;", + "}", + + "void main( void )", + "{", + "vec2 pos = gl_FragCoord.xy/resolution;", + "pos-=.5;", + "vec2 CausticDistortedDomain = CausticDistortDomainFn(pos);", + "float CausticShape = clamp(7.-length(CausticDistortedDomain.x*20.),0.,1.);", + "float CausticPattern = CausticPatternFn(CausticDistortedDomain);", + "float CausticOnFloor = CausticPatternFn(pos)+sin(pos.y*100.)*clamp(2.-length(pos*2.),0.,1.);", + "float Caustic;", + "Caustic += CausticShape*CausticPattern;", + "Caustic *= (pos.y+.5)/4.;", + "//Caustic += CausticOnFloor;", + "float f = length(pos+vec2(-.5,.5))*length(pos+vec2(.5,.5))*(1.+Caustic)/1.;", + + + "gl_FragColor = vec4(.1,.5,.6,1)*(f);", + + "}"]; + + +} + +PIXI.BinarySerpentsFilter.prototype = Object.create( PIXI.AbstractFilter.prototype ); +PIXI.BinarySerpentsFilter.prototype.constructor = PIXI.BinarySerpentsFilter; + +Object.defineProperty(PIXI.BinarySerpentsFilter.prototype, 'iGlobalTime', { + get: function() { + return this.uniforms.iGlobalTime.value; + }, + set: function(value) { + this.uniforms.iGlobalTime.value = value; + } +}); + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render }); + +function preload() { + + game.load.image('texture', 'wip/tex01.jpg'); + +} + +var filter; +var sprite; + +function create() { + + sprite = game.add.sprite(0, 0, 'texture'); + sprite.width = 800; + sprite.height = 600; + + filter = new PIXI.BinarySerpentsFilter(sprite.width, sprite.height, sprite.texture); + + sprite.filters = [filter]; + +} + +function update() { + + filter.iGlobalTime = game.time.totalElapsedSeconds(); + filter.uniforms.iMouse.value.x = game.input.x; + filter.uniforms.iMouse.value.y = game.input.y; + +} + +function render() { +} diff --git a/examples/wip/checkerWaveFilter.js b/examples/wip/checkerWaveFilter.js index e465f65f..b51469f2 100644 --- a/examples/wip/checkerWaveFilter.js +++ b/examples/wip/checkerWaveFilter.js @@ -14,9 +14,9 @@ PIXI.CheckerWaveFilter = function(width, height, texture) ]; this.uniforms = { - resolution: { type: 'f2', value: { x: width, y: height }}, - mouse: { type: 'f2', value: { x: 0, y: 0 }}, - time: { type: 'f', value: 1 } + resolution: { type: '2f', value: { x: width, y: height }}, + mouse: { type: '2f', value: { x: 0, y: 0 }}, + time: { type: '1f', value: 1 } }; // http://glsl.heroku.com/e#12260.0 diff --git a/examples/wip/deformStarFilter.js b/examples/wip/deformStarFilter.js index 6ec09516..45d1c5eb 100644 --- a/examples/wip/deformStarFilter.js +++ b/examples/wip/deformStarFilter.js @@ -14,10 +14,10 @@ PIXI.DeformStarFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, - iChannel0: { type: 'sampler2D', value: texture, wrap: 'repeat' } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, + iChannel0: { type: 'sampler2D', value: texture, textureData: { repeat: true } } }; // Shader by iq (https://www.shadertoy.com/view/4dXGRn) @@ -79,6 +79,7 @@ function preload() { // game.load.image('texture', 'wip/64x64.png'); game.load.image('texture', 'wip/tex08.jpg'); + game.load.image('texture2', 'assets/textures/alice.jpg'); } diff --git a/examples/wip/heroku.js b/examples/wip/heroku.js index 51da92a1..45472cce 100644 --- a/examples/wip/heroku.js +++ b/examples/wip/heroku.js @@ -14,9 +14,9 @@ PIXI.RayTracedBallsFilter = function(width, height, texture) ]; this.uniforms = { - resolution: { type: 'f2', value: { x: width, y: height }}, - mouse: { type: 'f2', value: { x: 0, y: 0 }}, - time: { type: 'f', value: 1 } + resolution: { type: '2f', value: { x: width, y: height }}, + mouse: { type: '2f', value: { x: 0, y: 0 }}, + time: { type: '1f', value: 1 } }; // http://glsl.heroku.com/e#12288.0 diff --git a/examples/wip/hueRotationFilter.js b/examples/wip/hueRotationFilter.js index 06cf3f48..e48472b9 100644 --- a/examples/wip/hueRotationFilter.js +++ b/examples/wip/hueRotationFilter.js @@ -14,9 +14,9 @@ PIXI.HueRotationFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, iChannel0: { type: 'sampler2D', value: texture } }; @@ -36,7 +36,7 @@ PIXI.HueRotationFilter = function(width, height, texture) "http://beesbuzz.biz/code/hsv_color_transforms.php", "*/", - "#define SPEED 10.0", + "#define SPEED 1.0", "void main(void)", "{", diff --git a/examples/wip/hypnoticRipplesFilter.js b/examples/wip/hypnoticRipplesFilter.js index 9809d7fa..d240ae18 100644 --- a/examples/wip/hypnoticRipplesFilter.js +++ b/examples/wip/hypnoticRipplesFilter.js @@ -14,9 +14,9 @@ PIXI.HypnoticRipplesFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, iChannel0: { type: 'sampler2D', value: texture } }; diff --git a/examples/wip/icosohedronFilter.js b/examples/wip/icosohedronFilter.js index 07e93d15..35bb6225 100644 --- a/examples/wip/icosohedronFilter.js +++ b/examples/wip/icosohedronFilter.js @@ -14,9 +14,9 @@ PIXI.IcosohedronFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, iChannel0: { type: 'sampler2D', value: texture } }; diff --git a/examples/wip/mengerTunnelFilter.js b/examples/wip/mengerTunnelFilter.js index cf724865..7e3b1613 100644 --- a/examples/wip/mengerTunnelFilter.js +++ b/examples/wip/mengerTunnelFilter.js @@ -14,9 +14,9 @@ PIXI.MengerTunnelFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, iChannel0: { type: 'sampler2D', value: texture, wrap: 'repeat' } }; diff --git a/examples/wip/metaBallsFilter.js b/examples/wip/metaBallsFilter.js index 0178fde2..67cc6c5e 100644 --- a/examples/wip/metaBallsFilter.js +++ b/examples/wip/metaBallsFilter.js @@ -14,10 +14,10 @@ PIXI.MetaBallsFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iMouse: { type: 'f3', value: { x: 0, y: 0, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iMouse: { type: '3f', value: { x: 0, y: 0, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, iChannel0: { type: 'sampler2D', value: texture, wrap: 'repeat' } }; diff --git a/examples/wip/mysteryVortexFilter.js b/examples/wip/mysteryVortexFilter.js index c3556375..c8915bc7 100644 --- a/examples/wip/mysteryVortexFilter.js +++ b/examples/wip/mysteryVortexFilter.js @@ -14,10 +14,10 @@ PIXI.MysteryVortexFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iMouse: { type: 'f3', value: { x: 0, y: 0, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iMouse: { type: '3f', value: { x: 0, y: 0, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, iChannel1: { type: 'sampler2D', value: texture, wrap: 'repeat' } }; diff --git a/examples/wip/planeDeformationFilter.js b/examples/wip/planeDeformationFilter.js index cb9e58e9..ad52b55d 100644 --- a/examples/wip/planeDeformationFilter.js +++ b/examples/wip/planeDeformationFilter.js @@ -14,11 +14,11 @@ PIXI.PlaneDeformationFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iMouse: { type: 'f3', value: { x: 0, y: 0, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, - iChannel0: { type: 'sampler2D', value: texture, wrap: 'repeat' } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iMouse: { type: '3f', value: { x: 0, y: 0, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, + iChannel0: { type: 'sampler2D', value: texture, textureData: { repeat: true } } }; // Shader by cce (https://www.shadertoy.com/view/XsXGWM) diff --git a/examples/wip/plasma3DFilter.js b/examples/wip/plasma3DFilter.js index cece3574..27cbfeb8 100644 --- a/examples/wip/plasma3DFilter.js +++ b/examples/wip/plasma3DFilter.js @@ -14,9 +14,9 @@ PIXI.Plasma3DFilter = function(width, height) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates } }; // Shader by Optimus (https://www.shadertoy.com/view/Mss3zn) diff --git a/examples/wip/plasmaBeamFilter.js b/examples/wip/plasmaBeamFilter.js index ac6ac32f..7b980de2 100644 --- a/examples/wip/plasmaBeamFilter.js +++ b/examples/wip/plasmaBeamFilter.js @@ -14,9 +14,9 @@ PIXI.PlasmaBeamFilter = function(width, height) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates } }; // Shader by 4rknova (https://www.shadertoy.com/view/Xsl3WH) diff --git a/examples/wip/pulsingInterferenceFilter.js b/examples/wip/pulsingInterferenceFilter.js index f6327a1f..63e3713b 100644 --- a/examples/wip/pulsingInterferenceFilter.js +++ b/examples/wip/pulsingInterferenceFilter.js @@ -14,10 +14,10 @@ PIXI.PulsingInterferenceFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iMouse: { type: 'f3', value: { x: 0, y: 0, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iMouse: { type: '3f', value: { x: 0, y: 0, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, iChannel0: { type: 'sampler2D', value: texture, wrap: 'repeat' } }; diff --git a/examples/wip/retroPlasmaFilter.js b/examples/wip/retroPlasmaFilter.js index 7507f673..0060e4d0 100644 --- a/examples/wip/retroPlasmaFilter.js +++ b/examples/wip/retroPlasmaFilter.js @@ -14,9 +14,9 @@ PIXI.RetroPlasmaFilter = function(width, height) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates } }; // Oldskool plasm shader. (c) Victor Korsun, bitekas@gmail.com; 1996-2013. diff --git a/examples/wip/rotationalFractalsFilter.js b/examples/wip/rotationalFractalsFilter.js index 5781f205..796df439 100644 --- a/examples/wip/rotationalFractalsFilter.js +++ b/examples/wip/rotationalFractalsFilter.js @@ -14,10 +14,10 @@ PIXI.RotationalFractalsFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iMouse: { type: 'f3', value: { x: 0, y: 0, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iMouse: { type: '3f', value: { x: 0, y: 0, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, iChannel0: { type: 'sampler2D', value: texture, wrap: 'repeat' } }; diff --git a/examples/wip/rotoZoomerFilter.js b/examples/wip/rotoZoomerFilter.js index e7ff2e76..7acc04f2 100644 --- a/examples/wip/rotoZoomerFilter.js +++ b/examples/wip/rotoZoomerFilter.js @@ -14,11 +14,11 @@ PIXI.RotoZoomerFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iMouse: { type: 'f3', value: { x: 0, y: 0, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, - iChannel0: { type: 'sampler2D', value: texture, wrap: 'nearest-repeat' } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iMouse: { type: '3f', value: { x: 0, y: 0, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, + iChannel0: { type: 'sampler2D', value: texture, textureData: { repeat: true } } }; // Shader by triggerHLM (https://www.shadertoy.com/view/lsfGDH) diff --git a/examples/wip/sineWaveFilter.js b/examples/wip/sineWaveFilter.js index 0634ad49..a22a4167 100644 --- a/examples/wip/sineWaveFilter.js +++ b/examples/wip/sineWaveFilter.js @@ -14,10 +14,10 @@ PIXI.SineWaveFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, - iChannel0: { type: 'sampler2D', value: texture, wrap: 'repeat' } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, + iChannel0: { type: 'sampler2D', value: texture, textureData: { repeat: true } } }; // Shader by Kali (https://www.shadertoy.com/view/4dfGDM) diff --git a/examples/wip/sineWaveFixedBaseFilter.js b/examples/wip/sineWaveFixedBaseFilter.js index b42370d1..131fe506 100644 --- a/examples/wip/sineWaveFixedBaseFilter.js +++ b/examples/wip/sineWaveFixedBaseFilter.js @@ -14,11 +14,11 @@ PIXI.SineWaveFixedBaseFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iMouse: { type: 'f3', value: { x: 0, y: 0, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, - iChannel0: { type: 'sampler2D', value: texture, wrap: 'repeat' } + iMouse: { type: '3f', value: { x: 0, y: 0, z: 0 }}, + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, + iChannel0: { type: 'sampler2D', value: texture, textureData: { repeat: true } } }; // Shader by BrokenBit (https://www.shadertoy.com/view/MsXGzX) diff --git a/examples/wip/starNestFilter.js b/examples/wip/starNestFilter.js index 4e18dccb..05b31f84 100644 --- a/examples/wip/starNestFilter.js +++ b/examples/wip/starNestFilter.js @@ -14,9 +14,9 @@ PIXI.StarNestFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, iChannel0: { type: 'sampler2D', value: texture } }; diff --git a/examples/wip/starNurseryFilter.js b/examples/wip/starNurseryFilter.js index dc7699fd..5808ad81 100644 --- a/examples/wip/starNurseryFilter.js +++ b/examples/wip/starNurseryFilter.js @@ -14,10 +14,10 @@ PIXI.StarNurseryFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, - iChannel0: { type: 'sampler2D', value: texture, wrap: 'repeat' } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, + iChannel0: { type: 'sampler2D', value: texture, textureData: { repeat: true } } }; // Shader by Dave Hoskins (https://www.shadertoy.com/view/XsfGzH) diff --git a/examples/wip/starfieldFilter.js b/examples/wip/starfieldFilter.js index e1d22f80..9c74109f 100644 --- a/examples/wip/starfieldFilter.js +++ b/examples/wip/starfieldFilter.js @@ -14,10 +14,10 @@ PIXI.StarFieldFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, - iChannel0: { type: 'sampler2D', value: texture, wrap: 'repeat' } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, + iChannel0: { type: 'sampler2D', value: texture, textureData: { repeat: true } } }; // Shader by Rebb / TRSI (https://www.shadertoy.com/view/XdX3Wn) diff --git a/examples/wip/starsBackgroundFilter.js b/examples/wip/starsBackgroundFilter.js index 93544c01..1ea51692 100644 --- a/examples/wip/starsBackgroundFilter.js +++ b/examples/wip/starsBackgroundFilter.js @@ -14,9 +14,9 @@ PIXI.StarsBackgroundFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, iChannel0: { type: 'sampler2D', value: texture } }; diff --git a/examples/wip/trippyLinesFilter.js b/examples/wip/trippyLinesFilter.js index 77c4c4f2..3b108d82 100644 --- a/examples/wip/trippyLinesFilter.js +++ b/examples/wip/trippyLinesFilter.js @@ -14,9 +14,9 @@ PIXI.TrippyLinesFilter = function(width, height) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates } }; // Shader by aji (https://www.shadertoy.com/view/lslGRj) diff --git a/examples/wip/vortexFilter.js b/examples/wip/vortexFilter.js index e8806816..769af791 100644 --- a/examples/wip/vortexFilter.js +++ b/examples/wip/vortexFilter.js @@ -14,10 +14,10 @@ PIXI.VortexFilter = function(width, height, texture) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, - iChannel0: { type: 'sampler2D', value: texture, wrap: 'repeat' } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, + iChannel0: { type: 'sampler2D', value: texture, textureData: { repeat: true } } }; // Shader by GhettoWolf (https://www.shadertoy.com/view/Xdl3WH) diff --git a/examples/wip/wobbleFilter.js b/examples/wip/wobbleFilter.js index 939b5897..1e69fe05 100644 --- a/examples/wip/wobbleFilter.js +++ b/examples/wip/wobbleFilter.js @@ -14,11 +14,11 @@ PIXI.WobbleFilter = function(width, height, texture0, texture1) ]; this.uniforms = { - iResolution: { type: 'f3', value: { x: width, y: height, z: 0 }}, - iGlobalTime: { type: 'f', value: 1 }, - iDate: { type: 'f4', value: dates }, - iChannel0: { type: 'sampler2D', value: texture0, wrap: 'repeat' }, - iChannel1: { type: 'sampler2D', value: texture1, wrap: 'repeat' } + iResolution: { type: '3f', value: { x: width, y: height, z: 0 }}, + iGlobalTime: { type: '1f', value: 1 }, + iDate: { type: '4fv', value: dates }, + iChannel0: { type: 'sampler2D', value: texture0, textureData: { repeat: true } }, + iChannel1: { type: 'sampler2D', value: texture1, textureData: { repeat: true } } }; // Shader by deps (https://www.shadertoy.com/view/MssGDM) diff --git a/filters/BinarySerpents.js b/filters/BinarySerpents.js index 34347d40..4db93e05 100644 --- a/filters/BinarySerpents.js +++ b/filters/BinarySerpents.js @@ -4,68 +4,68 @@ */ Phaser.Filter.BinarySerpents = function (game) { - Phaser.Filter.call(this, game); + Phaser.Filter.call(this, game); - this.uniforms.march = { type: '1i', value: 100 }; - this.uniforms.maxDistance = { type: '1f', value: 5.0 }; - this.uniforms.fog = { type: '1f', value: 5.0 }; - - this.fragmentSrc = [ + this.uniforms.march = { type: '1i', value: 100 }; + this.uniforms.maxDistance = { type: '1f', value: 5.0 }; + this.uniforms.fog = { type: '1f', value: 5.0 }; + + this.fragmentSrc = [ - "precision mediump float;", - "uniform vec3 resolution;", - "uniform float time;", - "uniform int march;", - "uniform float maxDistance;", - "uniform float fog;", + "precision mediump float;", + "uniform vec3 resolution;", + "uniform float time;", + "uniform int march;", + "uniform float maxDistance;", + "uniform float fog;", - "// With tweaks by PauloFalcao and Richard Davey", + "// With tweaks by PauloFalcao and Richard Davey", - "float Texture3D(vec3 n, float res) {", - "n = floor(n*res+.5);", - "return fract(sin((n.x+n.y*1e5+n.z*1e7)*1e-4)*1e5);", - "}", + "float Texture3D(vec3 n, float res) {", + "n = floor(n*res+.5);", + "return fract(sin((n.x+n.y*1e5+n.z*1e7)*1e-4)*1e5);", + "}", - "float map( vec3 p ) {", - "p.x+=sin(p.z*4.0+time*4.0)*0.1*cos(time*0.1);", - "p = mod(p,vec3(1.0, 1.0, 1.0))-0.5;", - "return length(p.xy)-.1;", - "}", + "float map( vec3 p ) {", + "p.x+=sin(p.z*4.0+time*4.0)*0.1*cos(time*0.1);", + "p = mod(p,vec3(1.0, 1.0, 1.0))-0.5;", + "return length(p.xy)-.1;", + "}", - "void main( void )", - "{", - "vec2 pos = (gl_FragCoord.xy*2.0 - resolution.xy) / resolution.y;", - "vec3 camPos = vec3(cos(time*0.3), sin(time*0.3), 1.5);", - "vec3 camTarget = vec3(0.0, 0.0, 0.0);", + "void main( void )", + "{", + "vec2 pos = (gl_FragCoord.xy*2.0 - resolution.xy) / resolution.y;", + "vec3 camPos = vec3(cos(time*0.3), sin(time*0.3), 1.5);", + "vec3 camTarget = vec3(0.0, 0.0, 0.0);", - "vec3 camDir = normalize(camTarget-camPos);", - "vec3 camUp = normalize(vec3(0.0, 1.0, 0.0));", - "vec3 camSide = cross(camDir, camUp);", - "float focus = 2.0;", + "vec3 camDir = normalize(camTarget-camPos);", + "vec3 camUp = normalize(vec3(0.0, 1.0, 0.0));", + "vec3 camSide = cross(camDir, camUp);", + "float focus = 2.0;", - "vec3 rayDir = normalize(camSide*pos.x + camUp*pos.y + camDir*focus);", - "vec3 ray = camPos;", - "float d = 0.0, total_d = 0.0;", - "const int MAX_MARCH = 100;", - "float c = 1.0;", + "vec3 rayDir = normalize(camSide*pos.x + camUp*pos.y + camDir*focus);", + "vec3 ray = camPos;", + "float d = 0.0, total_d = 0.0;", + "const int MAX_MARCH = 100;", + "float c = 1.0;", - "for (int i=0; i < MAX_MARCH; ++i) {", - "if (i < march) {", - "d = map(ray);", - "total_d += d;", - "ray += rayDir * d;", - "if(abs(d)<0.001) { break; }", - "if(total_d>maxDistance) { c = 0.; total_d=maxDistance; break; }", - "}", - "}", + "for (int i=0; i < MAX_MARCH; ++i) {", + "if (i < march) {", + "d = map(ray);", + "total_d += d;", + "ray += rayDir * d;", + "if(abs(d)<0.001) { break; }", + "if(total_d>maxDistance) { c = 0.; total_d=maxDistance; break; }", + "}", + "}", - "vec4 result = vec4( vec3(c*.4 , c*.6, c) * (fog - total_d) / fog, 1.0 );", + "vec4 result = vec4( vec3(c*.4 , c*.6, c) * (fog - total_d) / fog, 1.0 );", - "ray.z -= 5.+time*.5;", - "float r = Texture3D(ray, 33.);", - "gl_FragColor = result * (step(r, .3) + r * .2 + .1);", - "}" - ]; + "ray.z -= 5.+time*.5;", + "float r = Texture3D(ray, 33.);", + "gl_FragColor = result * (step(r, .3) + r * .2 + .1);", + "}" + ]; }; @@ -74,12 +74,12 @@ Phaser.Filter.BinarySerpents.prototype.constructor = Phaser.Filter.BinarySerpent Phaser.Filter.BinarySerpents.prototype.init = function (width, height, march, maxDistance) { - if (typeof march === 'undefined') { march = 100; } - if (typeof maxDistance === 'undefined') { maxDistance = 5.0; } + if (typeof march === 'undefined') { march = 100; } + if (typeof maxDistance === 'undefined') { maxDistance = 5.0; } - this.setResolution(width, height); - this.uniforms.march.value = march; - this.uniforms.maxDistance.value = maxDistance; + this.setResolution(width, height); + this.uniforms.march.value = march; + this.uniforms.maxDistance.value = maxDistance; } @@ -90,7 +90,7 @@ Object.defineProperty(Phaser.Filter.BinarySerpents.prototype, 'fog', { }, set: function(value) { - this.uniforms.fog.value = value; + this.uniforms.fog.value = value; } }); diff --git a/filters/CheckerWave.js b/filters/CheckerWave.js new file mode 100644 index 00000000..5e8deb94 --- /dev/null +++ b/filters/CheckerWave.js @@ -0,0 +1,171 @@ +/** +* Original shader from http://glsl.heroku.com/e#12260.0 +* Tweaked, uniforms added and converted to Phaser/PIXI by Richard Davey +*/ +Phaser.Filter.CheckerWave = function (game) { + + Phaser.Filter.call(this, game); + + this.uniforms.alpha = { type: '1f', value: 1.0 }; + this.uniforms.vrp = { type: '3f', value: { x: 0.0, y: -5.0, z: 0.0 }}; + this.uniforms.color1 = { type: '3f', value: { x: 0, y: 1, z: 1 }}; + this.uniforms.color2 = { type: '3f', value: { x: 1, y: 1, z: 1 }}; + + this.fragmentSrc = [ + + "precision mediump float;", + "uniform vec3 resolution;", + "uniform float time;", + "uniform float alpha;", + "uniform vec3 vrp;", + "uniform vec3 color1;", + "uniform vec3 color2;", + + "// Scene Start", + + "// Floor", + "vec2 obj0(in vec3 p) {", + "// obj deformation", + "p.y=p.y+sin(sqrt(p.x*p.x+p.z*p.z)-time*4.0)*0.5;", + "//plane", + "return vec2(p.y+3.0,0);", + "}", + + "// Floor Color (checkerboard)", + "vec3 obj0_c(in vec3 p) {", + "if (fract(p.x*.5)>.5)", + "if (fract(p.z*.5)>.5)", + "return color1;", + "else", + "return color2;", + "else", + "if (fract(p.z*.5)>.5)", + "return color2;", + "else", + "return color1;", + "}", + + "// Scene End", + + "void main(void) {", + "vec2 vPos=-1.0+2.0*gl_FragCoord.xy/resolution.xy;", + + "// Camera animation", + "vec3 vuv=vec3(0,2,sin(time*0.1));//Change camere up vector here", + "vec3 prp=vec3(-sin(time*0.6)*8.0,0,cos(time*0.4)*8.0); //Change camera path position here", + + "// Camera setup", + "vec3 vpn=normalize(vrp-prp);", + "vec3 u=normalize(cross(vuv,vpn));", + "vec3 v=cross(vpn,u);", + "vec3 vcv=(prp+vpn);", + "vec3 scrCoord=vcv+vPos.x*u*resolution.x/resolution.y+vPos.y*v;", + "vec3 scp=normalize(scrCoord-prp);", + + "// Raymarching", + "const vec3 e=vec3(0.1,0,0);", + "const float maxd=80.0; //Max depth", + + "vec2 s=vec2(0.1,0.0);", + "vec3 c,p,n;", + + "float f=1.0;", + + "for (int i=0;i<156;i++) {", + "if (abs(s.x)<.01||f>maxd) break;", + "f+=s.x;", + "p=prp+scp*f;", + "s=obj0(p);", + "}", + + "if (f