mirror of
https://github.com/wassname/phaser.git
synced 2026-07-02 17:00:42 +08:00
Fixed filters for new shader code.
This commit is contained in:
@@ -28,7 +28,9 @@
|
||||
<script src="$path/src/pixi/extras/Rope.js"></script>
|
||||
<script src="$path/src/pixi/extras/TilingSprite.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/filters/AbstractFilter.js"></script>
|
||||
<script src="$path/src/pixi/filters/FilterBlock.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/primitives/Graphics.js"></script>
|
||||
|
||||
<script src="$path/src/pixi/renderers/canvas/CanvasGraphics.js"></script>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -95,8 +95,6 @@ $(document).ready(function(){
|
||||
|
||||
.done(function(data) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
if (data.version !== '1.1.3')
|
||||
{
|
||||
$("#upgrade").append(data.version);
|
||||
|
||||
@@ -58,8 +58,6 @@ $(document).ready(function(){
|
||||
|
||||
.done(function(data) {
|
||||
|
||||
console.log(data);
|
||||
|
||||
if (data.version !== '1.1.3')
|
||||
{
|
||||
$("#upgrade").append(data.version);
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
@@ -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');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
@@ -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');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -9,10 +9,8 @@
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
// <script src="phaser.js"></script>
|
||||
<script src="../../../dist/phaser.min.js" type="text/javascript"></script>
|
||||
<script src="../../../filters/ColorBars.js" type="text/javascript"></script>
|
||||
<script src="../../../filters/BinarySerpents.js" type="text/javascript"></script>
|
||||
<script src="../../../filters/Fire.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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() {
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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');
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)",
|
||||
"{",
|
||||
|
||||
@@ -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 }
|
||||
};
|
||||
|
||||
|
||||
@@ -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 }
|
||||
};
|
||||
|
||||
|
||||
@@ -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' }
|
||||
};
|
||||
|
||||
|
||||
@@ -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' }
|
||||
};
|
||||
|
||||
|
||||
@@ -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' }
|
||||
};
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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' }
|
||||
};
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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' }
|
||||
};
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 }
|
||||
};
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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 }
|
||||
};
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
+57
-57
@@ -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;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -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<maxd) {",
|
||||
"if (s.y==0.0)",
|
||||
"c=obj0_c(p);",
|
||||
"n=normalize(",
|
||||
"vec3(s.x-obj0(p-e.xyy).x,",
|
||||
"s.x-obj0(p-e.yxy).x,",
|
||||
"s.x-obj0(p-e.yyx).x));",
|
||||
"float b=dot(n,normalize(prp-p));",
|
||||
"vec4 color = vec4(( b * c + pow(b, 8.0)) * (1.0 - f * .02), 1.0); //simple phong LightPosition=CameraPosition",
|
||||
"color.a = alpha;",
|
||||
"gl_FragColor=color;",
|
||||
"}",
|
||||
"else gl_FragColor=vec4(0,0,0.1,alpha); //background color",
|
||||
"}",
|
||||
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
Phaser.Filter.CheckerWave.prototype = Object.create(Phaser.Filter.prototype);
|
||||
Phaser.Filter.CheckerWave.prototype.constructor = Phaser.Filter.CheckerWave;
|
||||
|
||||
Phaser.Filter.CheckerWave.prototype.init = function (width, height) {
|
||||
|
||||
this.setResolution(width, height);
|
||||
|
||||
}
|
||||
|
||||
Phaser.Filter.CheckerWave.prototype.setColor1 = function (red, green, blue) {
|
||||
|
||||
this.uniforms.color1.value.x = red;
|
||||
this.uniforms.color1.value.y = green;
|
||||
this.uniforms.color1.value.z = blue;
|
||||
|
||||
}
|
||||
|
||||
Phaser.Filter.CheckerWave.prototype.setColor2 = function (red, green, blue) {
|
||||
|
||||
this.uniforms.color2.value.x = red;
|
||||
this.uniforms.color2.value.y = green;
|
||||
this.uniforms.color2.value.z = blue;
|
||||
|
||||
}
|
||||
|
||||
Object.defineProperty(Phaser.Filter.HueRotate.prototype, 'alpha', {
|
||||
|
||||
get: function() {
|
||||
return this.uniforms.alpha.value;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.alpha.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Filter.HueRotate.prototype, 'cameraX', {
|
||||
|
||||
get: function() {
|
||||
return this.uniforms.vrp.value.x;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.vrp.value.x = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Filter.HueRotate.prototype, 'cameraY', {
|
||||
|
||||
get: function() {
|
||||
return this.uniforms.vrp.value.y;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.vrp.value.y = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Object.defineProperty(Phaser.Filter.HueRotate.prototype, 'cameraZ', {
|
||||
|
||||
get: function() {
|
||||
return this.uniforms.vrp.value.z;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.vrp.value.z = value;
|
||||
}
|
||||
|
||||
});
|
||||
+49
-49
@@ -4,62 +4,62 @@
|
||||
*/
|
||||
Phaser.Filter.ColorBars = function (game) {
|
||||
|
||||
Phaser.Filter.call(this, game);
|
||||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.alpha = { type: '1f', value: 1 }
|
||||
// this.uniforms.origin = { type: '1f', value: 2.0 }
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"// bars - thygate@gmail.com",
|
||||
"// rotation and color mix modifications by malc (mlashley@gmail.com)",
|
||||
"// modified by @hintz 2013-04-30",
|
||||
this.uniforms.alpha = { type: '1f', value: 1 }
|
||||
// this.uniforms.origin = { type: '1f', value: 2.0 }
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"// bars - thygate@gmail.com",
|
||||
"// rotation and color mix modifications by malc (mlashley@gmail.com)",
|
||||
"// modified by @hintz 2013-04-30",
|
||||
|
||||
"precision mediump float;",
|
||||
"precision mediump float;",
|
||||
|
||||
"uniform vec3 resolution;",
|
||||
"uniform float time;",
|
||||
"uniform float alpha;",
|
||||
"uniform vec3 resolution;",
|
||||
"uniform float time;",
|
||||
"uniform float alpha;",
|
||||
|
||||
"vec2 position;",
|
||||
"vec4 color;",
|
||||
"vec2 position;",
|
||||
"vec4 color;",
|
||||
|
||||
"float f = 6.0;",
|
||||
"float f = 6.0;",
|
||||
|
||||
"float c = cos(time / 2.0);",
|
||||
"float s = sin(time / 2.0);",
|
||||
"mat2 R = mat2(c, -s, s, -c);",
|
||||
"float c = cos(time / 2.0);",
|
||||
"float s = sin(time / 2.0);",
|
||||
"mat2 R = mat2(c, -s, s, -c);",
|
||||
|
||||
"//float barsize = 0.15;",
|
||||
"float barsize = 0.12;",
|
||||
"//float barsangle = 200.0 * sin(time * 0.001);",
|
||||
"float barsangle = 200.0 * cos(time * 0.001);",
|
||||
"//float barsize = 0.15;",
|
||||
"float barsize = 0.12;",
|
||||
"//float barsangle = 200.0 * sin(time * 0.001);",
|
||||
"float barsangle = 200.0 * cos(time * 0.001);",
|
||||
|
||||
"vec4 bar(float pos, float r, float g, float b) {",
|
||||
"return max(0.0, 1.0 - abs(pos - position.y) / barsize) * vec4(r, g, b, 1.0);",
|
||||
"}",
|
||||
"vec4 bar(float pos, float r, float g, float b) {",
|
||||
"return max(0.0, 1.0 - abs(pos - position.y) / barsize) * vec4(r, g, b, 1.0);",
|
||||
"}",
|
||||
|
||||
"void main(void)",
|
||||
"{",
|
||||
"position = (gl_FragCoord.xy - 0.5 * resolution.xy) / resolution.xx;",
|
||||
"//position = 2.0 * position * R; // R = rotation",
|
||||
"position = 2.5 * position * R;",
|
||||
"//float t = time * 0.5; // 0.5 = spin speed",
|
||||
"float t = time * 0.5;",
|
||||
"vec4 color = vec4(0.0);",
|
||||
"color += bar(sin(t), 1.0, 0.0, 0.0);",
|
||||
"color += bar(sin(t + barsangle / f * 2.), 1.0, 0.5, 0.0);",
|
||||
"color += bar(sin(t + barsangle / f * 4.), 1.0, 1.0, 0.0);",
|
||||
"color += bar(sin(t + barsangle / f * 6.), 0.0, 1.0, 0.0);",
|
||||
"color += bar(sin(t + barsangle / f * 8.), 0.0, 1.0, 1.0);",
|
||||
"color += bar(sin(t + barsangle / f * 10.), 0.0, 0.0, 1.0);",
|
||||
"color += bar(sin(t + barsangle / f * 12.), 0.5, 0.0, 1.0);",
|
||||
"color += bar(sin(t + barsangle / f * 14.), 1.0, 0.0, 1.0);",
|
||||
"color.a = alpha;",
|
||||
"gl_FragColor = color;",
|
||||
"}"
|
||||
|
||||
];
|
||||
"void main(void)",
|
||||
"{",
|
||||
"position = (gl_FragCoord.xy - 0.5 * resolution.xy) / resolution.xx;",
|
||||
"//position = 2.0 * position * R; // R = rotation",
|
||||
"position = 2.5 * position * R;",
|
||||
"//float t = time * 0.5; // 0.5 = spin speed",
|
||||
"float t = time * 0.5;",
|
||||
"vec4 color = vec4(0.0);",
|
||||
"color += bar(sin(t), 1.0, 0.0, 0.0);",
|
||||
"color += bar(sin(t + barsangle / f * 2.), 1.0, 0.5, 0.0);",
|
||||
"color += bar(sin(t + barsangle / f * 4.), 1.0, 1.0, 0.0);",
|
||||
"color += bar(sin(t + barsangle / f * 6.), 0.0, 1.0, 0.0);",
|
||||
"color += bar(sin(t + barsangle / f * 8.), 0.0, 1.0, 1.0);",
|
||||
"color += bar(sin(t + barsangle / f * 10.), 0.0, 0.0, 1.0);",
|
||||
"color += bar(sin(t + barsangle / f * 12.), 0.5, 0.0, 1.0);",
|
||||
"color += bar(sin(t + barsangle / f * 14.), 1.0, 0.0, 1.0);",
|
||||
"color.a = alpha;",
|
||||
"gl_FragColor = color;",
|
||||
"}"
|
||||
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ Phaser.Filter.ColorBars.prototype.constructor = Phaser.Filter.ColorBars;
|
||||
|
||||
Phaser.Filter.ColorBars.prototype.init = function (width, height) {
|
||||
|
||||
this.setResolution(width, height);
|
||||
this.setResolution(width, height);
|
||||
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ Object.defineProperty(Phaser.Filter.ColorBars.prototype, 'alpha', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.alpha.value = value;
|
||||
this.uniforms.alpha.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
+52
-52
@@ -4,57 +4,57 @@
|
||||
*/
|
||||
Phaser.Filter.Fire = function (game) {
|
||||
|
||||
Phaser.Filter.call(this, game);
|
||||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.alpha = { type: '1f', value: 1.0 }
|
||||
this.uniforms.shift = { type: '1f', value: 1.6 }
|
||||
this.uniforms.speed = { type: '2f', value: { x: 0.7, y: 0.4 } };
|
||||
this.uniforms.alpha = { type: '1f', value: 1.0 }
|
||||
this.uniforms.shift = { type: '1f', value: 1.6 }
|
||||
this.uniforms.speed = { type: '2f', value: { x: 0.7, y: 0.4 } };
|
||||
|
||||
this.fragmentSrc = [
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
"uniform vec3 resolution;",
|
||||
"uniform float time;",
|
||||
"uniform float alpha;",
|
||||
"uniform vec2 speed;",
|
||||
"uniform float shift;",
|
||||
"precision mediump float;",
|
||||
"uniform vec3 resolution;",
|
||||
"uniform float time;",
|
||||
"uniform float alpha;",
|
||||
"uniform vec2 speed;",
|
||||
"uniform float shift;",
|
||||
|
||||
"float rand(vec2 n) {",
|
||||
"return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);",
|
||||
"}",
|
||||
"float rand(vec2 n) {",
|
||||
"return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);",
|
||||
"}",
|
||||
|
||||
"float noise(vec2 n) {",
|
||||
"const vec2 d = vec2(0.0, 1.0);",
|
||||
"vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));",
|
||||
"return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);",
|
||||
"}",
|
||||
"float noise(vec2 n) {",
|
||||
"const vec2 d = vec2(0.0, 1.0);",
|
||||
"vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));",
|
||||
"return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);",
|
||||
"}",
|
||||
|
||||
"float fbm(vec2 n) {",
|
||||
"float total = 0.0, amplitude = 1.0;",
|
||||
"for (int i = 0; i < 4; i++) {",
|
||||
"total += noise(n) * amplitude;",
|
||||
"n += n;",
|
||||
"amplitude *= 0.5;",
|
||||
"}",
|
||||
"return total;",
|
||||
"}",
|
||||
"float fbm(vec2 n) {",
|
||||
"float total = 0.0, amplitude = 1.0;",
|
||||
"for (int i = 0; i < 4; i++) {",
|
||||
"total += noise(n) * amplitude;",
|
||||
"n += n;",
|
||||
"amplitude *= 0.5;",
|
||||
"}",
|
||||
"return total;",
|
||||
"}",
|
||||
|
||||
"void main() {",
|
||||
"void main() {",
|
||||
|
||||
"const vec3 c1 = vec3(0.5, 0.0, 0.1);",
|
||||
"const vec3 c2 = vec3(0.9, 0.0, 0.0);",
|
||||
"const vec3 c3 = vec3(0.2, 0.0, 0.0);",
|
||||
"const vec3 c4 = vec3(1.0, 0.9, 0.0);",
|
||||
"const vec3 c5 = vec3(0.1);",
|
||||
"const vec3 c6 = vec3(0.9);",
|
||||
"const vec3 c1 = vec3(0.5, 0.0, 0.1);",
|
||||
"const vec3 c2 = vec3(0.9, 0.0, 0.0);",
|
||||
"const vec3 c3 = vec3(0.2, 0.0, 0.0);",
|
||||
"const vec3 c4 = vec3(1.0, 0.9, 0.0);",
|
||||
"const vec3 c5 = vec3(0.1);",
|
||||
"const vec3 c6 = vec3(0.9);",
|
||||
|
||||
"vec2 p = gl_FragCoord.xy * 8.0 / resolution.xx;",
|
||||
"float q = fbm(p - time * 0.1);",
|
||||
"vec2 r = vec2(fbm(p + q + time * speed.x - p.x - p.y), fbm(p + q - time * speed.y));",
|
||||
"vec3 c = mix(c1, c2, fbm(p + r)) + mix(c3, c4, r.x) - mix(c5, c6, r.y);",
|
||||
"gl_FragColor = vec4(c * cos(shift * gl_FragCoord.y / resolution.y), alpha);",
|
||||
"}"
|
||||
];
|
||||
"vec2 p = gl_FragCoord.xy * 8.0 / resolution.xx;",
|
||||
"float q = fbm(p - time * 0.1);",
|
||||
"vec2 r = vec2(fbm(p + q + time * speed.x - p.x - p.y), fbm(p + q - time * speed.y));",
|
||||
"vec3 c = mix(c1, c2, fbm(p + r)) + mix(c3, c4, r.x) - mix(c5, c6, r.y);",
|
||||
"gl_FragColor = vec4(c * cos(shift * gl_FragCoord.y / resolution.y), alpha);",
|
||||
"}"
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
@@ -63,15 +63,15 @@ Phaser.Filter.Fire.prototype.constructor = Phaser.Filter.Fire;
|
||||
|
||||
Phaser.Filter.Fire.prototype.init = function (width, height, alpha, shift) {
|
||||
|
||||
this.setResolution(width, height);
|
||||
this.setResolution(width, height);
|
||||
|
||||
if (typeof alpha !== 'undefined') {
|
||||
this.uniforms.alpha.value = alpha;
|
||||
}
|
||||
if (typeof alpha !== 'undefined') {
|
||||
this.uniforms.alpha.value = alpha;
|
||||
}
|
||||
|
||||
if (typeof shift !== 'undefined') {
|
||||
this.uniforms.shift.value = shift;
|
||||
}
|
||||
if (typeof shift !== 'undefined') {
|
||||
this.uniforms.shift.value = shift;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ Object.defineProperty(Phaser.Filter.Fire.prototype, 'alpha', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.alpha.value = value;
|
||||
this.uniforms.alpha.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -94,7 +94,7 @@ Object.defineProperty(Phaser.Filter.Fire.prototype, 'shift', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.shift.value = value;
|
||||
this.uniforms.shift.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -106,7 +106,7 @@ Object.defineProperty(Phaser.Filter.Fire.prototype, 'speed', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.speed.value = value;
|
||||
this.uniforms.speed.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Original shader by Daniil (https://www.shadertoy.com/view/4sl3DH)
|
||||
* Tweaked, uniforms added and converted to Phaser/PIXI by Richard Davey
|
||||
*/
|
||||
Phaser.Filter.HueRotate = function (game) {
|
||||
|
||||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.alpha = { type: '1f', value: 1.0 };
|
||||
this.uniforms.size = { type: '1f', value: 0.03 };
|
||||
this.uniforms.iChannel0 = { type: 'sampler2D', value: null, textureData: { repeat: true } }
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
"uniform vec3 resolution;",
|
||||
"uniform float time;",
|
||||
"uniform float alpha;",
|
||||
"uniform sampler2D iChannel0;",
|
||||
|
||||
"/* Simple hue rotation filter based on article:",
|
||||
"http://beesbuzz.biz/code/hsv_color_transforms.php",
|
||||
"*/",
|
||||
|
||||
"#define SPEED 10.0",
|
||||
|
||||
"void main(void)",
|
||||
"{",
|
||||
"vec2 uv = gl_FragCoord.xy / resolution.xy;",
|
||||
|
||||
"float c = cos(time * SPEED);",
|
||||
"float s = sin(time * SPEED);",
|
||||
|
||||
"mat4 hueRotation =",
|
||||
"mat4( 0.299, 0.587, 0.114, 0.0,",
|
||||
"0.299, 0.587, 0.114, 0.0,",
|
||||
"0.299, 0.587, 0.114, 0.0,",
|
||||
"0.000, 0.000, 0.000, 1.0) +",
|
||||
|
||||
"mat4( 0.701, -0.587, -0.114, 0.0,",
|
||||
"-0.299, 0.413, -0.114, 0.0,",
|
||||
"-0.300, -0.588, 0.886, 0.0,",
|
||||
"0.000, 0.000, 0.000, 0.0) * c +",
|
||||
|
||||
"mat4( 0.168, 0.330, -0.497, 0.0,",
|
||||
"-0.328, 0.035, 0.292, 0.0,",
|
||||
"1.250, -1.050, -0.203, 0.0,",
|
||||
"0.000, 0.000, 0.000, 0.0) * s;",
|
||||
|
||||
"vec4 pixel = texture2D(iChannel0, uv);",
|
||||
|
||||
"gl_FragColor = pixel * hueRotation;",
|
||||
"}"
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
Phaser.Filter.HueRotate.prototype = Object.create(Phaser.Filter.prototype);
|
||||
Phaser.Filter.HueRotate.prototype.constructor = Phaser.Filter.HueRotate;
|
||||
|
||||
Phaser.Filter.HueRotate.prototype.init = function (width, height, texture) {
|
||||
|
||||
this.setResolution(width, height);
|
||||
|
||||
this.uniforms.iChannel0.value = texture;
|
||||
|
||||
}
|
||||
|
||||
Object.defineProperty(Phaser.Filter.HueRotate.prototype, 'alpha', {
|
||||
|
||||
get: function() {
|
||||
return this.uniforms.alpha.value;
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.alpha.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
+43
-43
@@ -4,47 +4,47 @@
|
||||
*/
|
||||
Phaser.Filter.LightBeam = function (game) {
|
||||
|
||||
Phaser.Filter.call(this, game);
|
||||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.alpha = { type: '1f', value: 1 }
|
||||
this.uniforms.thickness = { type: '1f', value: 70.0 }
|
||||
this.uniforms.speed = { type: '1f', value: 1.0 }
|
||||
this.uniforms.red = { type: '1f', value: 2.0 }
|
||||
this.uniforms.green = { type: '1f', value: 1.0 }
|
||||
this.uniforms.blue = { type: '1f', value: 1.0 }
|
||||
|
||||
this.fragmentSrc = [
|
||||
this.uniforms.alpha = { type: '1f', value: 1 }
|
||||
this.uniforms.thickness = { type: '1f', value: 70.0 }
|
||||
this.uniforms.speed = { type: '1f', value: 1.0 }
|
||||
this.uniforms.red = { type: '1f', value: 2.0 }
|
||||
this.uniforms.green = { type: '1f', value: 1.0 }
|
||||
this.uniforms.blue = { type: '1f', value: 1.0 }
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
"uniform vec3 resolution;",
|
||||
"uniform float time;",
|
||||
"uniform float alpha;",
|
||||
"uniform float thickness;",
|
||||
"uniform float speed;",
|
||||
"uniform float red;",
|
||||
"uniform float green;",
|
||||
"uniform float blue;",
|
||||
"precision mediump float;",
|
||||
"uniform vec3 resolution;",
|
||||
"uniform float time;",
|
||||
"uniform float alpha;",
|
||||
"uniform float thickness;",
|
||||
"uniform float speed;",
|
||||
"uniform float red;",
|
||||
"uniform float green;",
|
||||
"uniform float blue;",
|
||||
|
||||
"void main(void) {",
|
||||
"void main(void) {",
|
||||
|
||||
"vec2 uPos = (gl_FragCoord.xy / resolution.xy);",
|
||||
|
||||
"uPos.y -= 0.50;",
|
||||
|
||||
"float vertColor = 0.0;",
|
||||
"vec2 uPos = (gl_FragCoord.xy / resolution.xy);",
|
||||
|
||||
"uPos.y -= 0.50;",
|
||||
|
||||
"float vertColor = 0.0;",
|
||||
|
||||
"for (float i = 0.0; i < 1.0; i++)",
|
||||
"{",
|
||||
"float t = time * (i + speed);",
|
||||
"uPos.y += sin(uPos.x + t) * 0.2;",
|
||||
"float fTemp = abs(1.0 / uPos.y / thickness);",
|
||||
"vertColor += fTemp;",
|
||||
"}",
|
||||
|
||||
"vec4 color = vec4(vertColor * red, vertColor * green, vertColor * blue, alpha);",
|
||||
"gl_FragColor = color;",
|
||||
"}"
|
||||
];
|
||||
"for (float i = 0.0; i < 1.0; i++)",
|
||||
"{",
|
||||
"float t = time * (i + speed);",
|
||||
"uPos.y += sin(uPos.x + t) * 0.2;",
|
||||
"float fTemp = abs(1.0 / uPos.y / thickness);",
|
||||
"vertColor += fTemp;",
|
||||
"}",
|
||||
|
||||
"vec4 color = vec4(vertColor * red, vertColor * green, vertColor * blue, alpha);",
|
||||
"gl_FragColor = color;",
|
||||
"}"
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
@@ -53,7 +53,7 @@ Phaser.Filter.LightBeam.prototype.constructor = Phaser.Filter.LightBeam;
|
||||
|
||||
Phaser.Filter.LightBeam.prototype.init = function (width, height) {
|
||||
|
||||
this.setResolution(width, height);
|
||||
this.setResolution(width, height);
|
||||
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ Object.defineProperty(Phaser.Filter.LightBeam.prototype, 'alpha', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.alpha.value = value;
|
||||
this.uniforms.alpha.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -76,7 +76,7 @@ Object.defineProperty(Phaser.Filter.LightBeam.prototype, 'red', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.red.value = value;
|
||||
this.uniforms.red.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -88,7 +88,7 @@ Object.defineProperty(Phaser.Filter.LightBeam.prototype, 'green', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.green.value = value;
|
||||
this.uniforms.green.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -100,7 +100,7 @@ Object.defineProperty(Phaser.Filter.LightBeam.prototype, 'blue', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.blue.value = value;
|
||||
this.uniforms.blue.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -112,7 +112,7 @@ Object.defineProperty(Phaser.Filter.LightBeam.prototype, 'thickness', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.thickness.value = value;
|
||||
this.uniforms.thickness.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -124,7 +124,7 @@ Object.defineProperty(Phaser.Filter.LightBeam.prototype, 'speed', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.speed.value = value;
|
||||
this.uniforms.speed.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
+41
-41
@@ -4,44 +4,44 @@
|
||||
*/
|
||||
Phaser.Filter.Plasma = function (game) {
|
||||
|
||||
Phaser.Filter.call(this, game);
|
||||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.alpha = { type: '1f', value: 1.0 };
|
||||
this.uniforms.size = { type: '1f', value: 0.03 };
|
||||
this.uniforms.redShift = { type: '1f', value: 0.5 };
|
||||
this.uniforms.greenShift = { type: '1f', value: 0.5 };
|
||||
this.uniforms.blueShift = { type: '1f', value: 0.9 };
|
||||
|
||||
this.fragmentSrc = [
|
||||
this.uniforms.alpha = { type: '1f', value: 1.0 };
|
||||
this.uniforms.size = { type: '1f', value: 0.03 };
|
||||
this.uniforms.redShift = { type: '1f', value: 0.5 };
|
||||
this.uniforms.greenShift = { type: '1f', value: 0.5 };
|
||||
this.uniforms.blueShift = { type: '1f', value: 0.9 };
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
"uniform float time;",
|
||||
"uniform float alpha;",
|
||||
"uniform float size;",
|
||||
"uniform float redShift;",
|
||||
"uniform float greenShift;",
|
||||
"uniform float blueShift;",
|
||||
"precision mediump float;",
|
||||
"uniform float time;",
|
||||
"uniform float alpha;",
|
||||
"uniform float size;",
|
||||
"uniform float redShift;",
|
||||
"uniform float greenShift;",
|
||||
"uniform float blueShift;",
|
||||
|
||||
"const float PI = 3.14159265;",
|
||||
"const float PI = 3.14159265;",
|
||||
|
||||
"float ptime = time * 0.1;",
|
||||
"float ptime = time * 0.1;",
|
||||
|
||||
"void main(void) {",
|
||||
"void main(void) {",
|
||||
|
||||
"float color1, color2, color;",
|
||||
"float color1, color2, color;",
|
||||
|
||||
"color1 = (sin(dot(gl_FragCoord.xy, vec2(sin(ptime * 3.0), cos(ptime * 3.0))) * 0.02 + ptime * 3.0) + 1.0) / 2.0;",
|
||||
"vec2 center = vec2(640.0 / 2.0, 360.0 / 2.0) + vec2(640.0 / 2.0 * sin(-ptime * 3.0), 360.0 / 2.0 * cos(-ptime * 3.0));",
|
||||
"color2 = (cos(length(gl_FragCoord.xy - center) * size) + 1.0) / 2.0;",
|
||||
"color = (color1 + color2) / 2.0;",
|
||||
"color1 = (sin(dot(gl_FragCoord.xy, vec2(sin(ptime * 3.0), cos(ptime * 3.0))) * 0.02 + ptime * 3.0) + 1.0) / 2.0;",
|
||||
"vec2 center = vec2(640.0 / 2.0, 360.0 / 2.0) + vec2(640.0 / 2.0 * sin(-ptime * 3.0), 360.0 / 2.0 * cos(-ptime * 3.0));",
|
||||
"color2 = (cos(length(gl_FragCoord.xy - center) * size) + 1.0) / 2.0;",
|
||||
"color = (color1 + color2) / 2.0;",
|
||||
|
||||
"float red = (cos(PI * color / redShift + ptime * 3.0) + 1.0) / 2.0;",
|
||||
"float green = (sin(PI * color / greenShift + ptime * 3.0) + 1.0) / 2.0;",
|
||||
"float blue = (sin(PI * color / blueShift + ptime * 3.0) + 1.0) / 2.0;",
|
||||
"float red = (cos(PI * color / redShift + ptime * 3.0) + 1.0) / 2.0;",
|
||||
"float green = (sin(PI * color / greenShift + ptime * 3.0) + 1.0) / 2.0;",
|
||||
"float blue = (sin(PI * color / blueShift + ptime * 3.0) + 1.0) / 2.0;",
|
||||
|
||||
"gl_FragColor = vec4(red, green, blue, alpha);",
|
||||
"}"
|
||||
];
|
||||
"gl_FragColor = vec4(red, green, blue, alpha);",
|
||||
"}"
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
@@ -50,15 +50,15 @@ Phaser.Filter.Plasma.prototype.constructor = Phaser.Filter.Plasma;
|
||||
|
||||
Phaser.Filter.Plasma.prototype.init = function (width, height, alpha, size) {
|
||||
|
||||
this.setResolution(width, height);
|
||||
this.setResolution(width, height);
|
||||
|
||||
if (typeof alpha !== 'undefined') {
|
||||
this.uniforms.alpha.value = alpha;
|
||||
}
|
||||
if (typeof alpha !== 'undefined') {
|
||||
this.uniforms.alpha.value = alpha;
|
||||
}
|
||||
|
||||
if (typeof size !== 'undefined') {
|
||||
this.uniforms.size.value = size;
|
||||
}
|
||||
if (typeof size !== 'undefined') {
|
||||
this.uniforms.size.value = size;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ Object.defineProperty(Phaser.Filter.Plasma.prototype, 'alpha', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.alpha.value = value;
|
||||
this.uniforms.alpha.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -81,7 +81,7 @@ Object.defineProperty(Phaser.Filter.Plasma.prototype, 'size', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.size.value = value;
|
||||
this.uniforms.size.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -93,7 +93,7 @@ Object.defineProperty(Phaser.Filter.Plasma.prototype, 'redShift', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.redShift.value = value;
|
||||
this.uniforms.redShift.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -105,7 +105,7 @@ Object.defineProperty(Phaser.Filter.Plasma.prototype, 'greenShift', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.greenShift.value = value;
|
||||
this.uniforms.greenShift.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -117,7 +117,7 @@ Object.defineProperty(Phaser.Filter.Plasma.prototype, 'blueShift', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.blueShift.value = value;
|
||||
this.uniforms.blueShift.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
+31
-31
@@ -3,38 +3,38 @@
|
||||
*/
|
||||
Phaser.Filter.SampleFilter = function (game) {
|
||||
|
||||
Phaser.Filter.call(this, game);
|
||||
Phaser.Filter.call(this, game);
|
||||
|
||||
/**
|
||||
* By default the following uniforms are already created and available:
|
||||
*
|
||||
* uniform float time - The current number of elapsed milliseconds in the game.
|
||||
* uniform vec3 resolution - The dimensions of the filter. Can be set via setSize(width, height)
|
||||
* uniform vec4 mouse - The mouse / touch coordinates taken from the pointer given to the update function, if any.
|
||||
* uniform sampler2D uSampler - The current texture (usually the texture of the Sprite the shader is bound to)
|
||||
*
|
||||
* Add in any additional vars you require. Here is a new one called 'wobble' that is a 2f:
|
||||
*
|
||||
* this.uniforms.wobble = { type: '2f', value: { x: 0, y: 0 }};
|
||||
*
|
||||
* The supported types are: 1f, 1fv, 1i, 2f, 2fv, 2i, 2iv, 3f, 3fv, 3i, 3iv, 4f, 4fv, 4i, 4iv, mat2, mat3, mat4 and sampler2D.
|
||||
*/
|
||||
/**
|
||||
* By default the following uniforms are already created and available:
|
||||
*
|
||||
* uniform float time - The current number of elapsed milliseconds in the game.
|
||||
* uniform vec3 resolution - The dimensions of the filter. Can be set via setSize(width, height)
|
||||
* uniform vec4 mouse - The mouse / touch coordinates taken from the pointer given to the update function, if any.
|
||||
* uniform sampler2D uSampler - The current texture (usually the texture of the Sprite the shader is bound to)
|
||||
*
|
||||
* Add in any additional vars you require. Here is a new one called 'wobble' that is a 2f:
|
||||
*
|
||||
* this.uniforms.wobble = { type: '2f', value: { x: 0, y: 0 }};
|
||||
*
|
||||
* The supported types are: 1f, 1fv, 1i, 2f, 2fv, 2i, 2iv, 3f, 3fv, 3i, 3iv, 4f, 4fv, 4i, 4iv, mat2, mat3, mat4 and sampler2D.
|
||||
*/
|
||||
|
||||
this.uniforms.divisor = { type: '1f', value: 0.5 };
|
||||
|
||||
// The fragment shader source
|
||||
this.fragmentSrc = [
|
||||
this.uniforms.divisor = { type: '1f', value: 0.5 };
|
||||
|
||||
// The fragment shader source
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
"uniform vec3 resolution;",
|
||||
"uniform float time;",
|
||||
"uniform float divisor;",
|
||||
"precision mediump float;",
|
||||
"uniform vec3 resolution;",
|
||||
"uniform float time;",
|
||||
"uniform float divisor;",
|
||||
|
||||
"void main(void) {",
|
||||
"vec2 uv = gl_FragCoord.xy / resolution.xy;",
|
||||
"gl_FragColor = vec4(uv, divisor * sin(time), 0.0);",
|
||||
"}"
|
||||
];
|
||||
"void main(void) {",
|
||||
"vec2 uv = gl_FragCoord.xy / resolution.xy;",
|
||||
"gl_FragColor = vec4(uv, divisor * sin(time), 0.0);",
|
||||
"}"
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
@@ -43,9 +43,9 @@ Phaser.Filter.SampleFilter.prototype.constructor = Phaser.Filter.SampleFilter;
|
||||
|
||||
Phaser.Filter.SampleFilter.prototype.init = function (width, height, divisor) {
|
||||
|
||||
if (typeof divisor == 'undefined') { divisor = 0.5 };
|
||||
if (typeof divisor == 'undefined') { divisor = 0.5 };
|
||||
|
||||
this.setResolution(width, height);
|
||||
this.uniforms.divisor.value = divisor;
|
||||
this.setResolution(width, height);
|
||||
this.uniforms.divisor.value = divisor;
|
||||
|
||||
}
|
||||
|
||||
+26
-26
@@ -4,33 +4,33 @@
|
||||
*/
|
||||
Phaser.Filter.Tunnel = function (game) {
|
||||
|
||||
Phaser.Filter.call(this, game);
|
||||
Phaser.Filter.call(this, game);
|
||||
|
||||
this.uniforms.alpha = { type: '1f', value: 1 }
|
||||
this.uniforms.origin = { type: '1f', value: 2.0 }
|
||||
this.uniforms.iChannel0 = { type: 'sampler2D', value: null, textureData: { repeat: true } }
|
||||
|
||||
this.fragmentSrc = [
|
||||
this.uniforms.alpha = { type: '1f', value: 1 }
|
||||
this.uniforms.origin = { type: '1f', value: 2.0 }
|
||||
this.uniforms.iChannel0 = { type: 'sampler2D', value: null, textureData: { repeat: true } }
|
||||
|
||||
this.fragmentSrc = [
|
||||
|
||||
"precision mediump float;",
|
||||
"uniform vec3 resolution;",
|
||||
"uniform float time;",
|
||||
"uniform sampler2D iChannel0;",
|
||||
"uniform float alpha;",
|
||||
"uniform float origin;",
|
||||
"precision mediump float;",
|
||||
"uniform vec3 resolution;",
|
||||
"uniform float time;",
|
||||
"uniform sampler2D iChannel0;",
|
||||
"uniform float alpha;",
|
||||
"uniform float origin;",
|
||||
|
||||
"#define S 0.79577471545 // Precalculated 2.5 / PI",
|
||||
"#define E 0.0001",
|
||||
"#define S 0.79577471545 // Precalculated 2.5 / PI",
|
||||
"#define E 0.0001",
|
||||
|
||||
"void main(void)",
|
||||
"{",
|
||||
"vec2 p = (origin * gl_FragCoord.xy / resolution.xy - 1.0) * vec2(resolution.x / resolution.y, 1.0);",
|
||||
"vec2 t = vec2(S * atan(p.x, p.y), 1.0 / max(length(p), E));",
|
||||
"vec3 c = texture2D(iChannel0, t + vec2(time * 0.1, time)).xyz;",
|
||||
"gl_FragColor = vec4(c / (t.y + 0.5), alpha);",
|
||||
"}"
|
||||
"void main(void)",
|
||||
"{",
|
||||
"vec2 p = (origin * gl_FragCoord.xy / resolution.xy - 1.0) * vec2(resolution.x / resolution.y, 1.0);",
|
||||
"vec2 t = vec2(S * atan(p.x, p.y), 1.0 / max(length(p), E));",
|
||||
"vec3 c = texture2D(iChannel0, t + vec2(time * 0.1, time)).xyz;",
|
||||
"gl_FragColor = vec4(c / (t.y + 0.5), alpha);",
|
||||
"}"
|
||||
|
||||
];
|
||||
];
|
||||
|
||||
};
|
||||
|
||||
@@ -39,8 +39,8 @@ Phaser.Filter.Tunnel.prototype.constructor = Phaser.Filter.Tunnel;
|
||||
|
||||
Phaser.Filter.Tunnel.prototype.init = function (width, height, texture) {
|
||||
|
||||
this.setResolution(width, height);
|
||||
this.uniforms.iChannel0.value = texture;
|
||||
this.setResolution(width, height);
|
||||
this.uniforms.iChannel0.value = texture;
|
||||
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ Object.defineProperty(Phaser.Filter.Tunnel.prototype, 'alpha', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.alpha.value = value;
|
||||
this.uniforms.alpha.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -63,7 +63,7 @@ Object.defineProperty(Phaser.Filter.Tunnel.prototype, 'origin', {
|
||||
},
|
||||
|
||||
set: function(value) {
|
||||
this.uniforms.origin.value = value;
|
||||
this.uniforms.origin.value = value;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 448 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 142 KiB |
Reference in New Issue
Block a user