Quantcast
Viewing latest article 1
Browse Latest Browse All 56

Pass uniforms to Filter's shader

I wanna implement this shader (https://www.shadertoy.com/view/MslGWN#) in PhaserJS state.
So i transformed the shader to WebGL style.
I overload Phaser.Filter’s update function to pass iChannel uniforms:

Phaser.Filter.prototype.update = function (pointer, uniforms) {
   if (typeof pointer !== 'undefined')
   {
       var x = pointer.x / this.game.width;
       var y = 1 - pointer.y / this.game.height;

       if (x !== this.prevPoint.x || y !== this.prevPoint.y)
       {
           this.uniforms.mouse.value.x = x.toFixed(2);
           this.uniforms.mouse.value.y = y.toFixed(2);
           this.prevPoint.set(x, y);
       }
   }
   if (typeof uniforms !== 'undefined')
   {
       for (var i in uniforms) {
           this.uniforms[i].value = uniforms[i];
       }
   }

   this.uniforms.time.value = this.game.time.totalElapsedSeconds();
}

But it does not helped. There is no affection from music to fractal generation. Like i do pass null’s.
Here is jsbin to play with http://jsbin.com/yutiwejoja/1/edit?js,output

Where am i wrong?
It’s about three days i am trying to fight it… thanks a lot!


Viewing latest article 1
Browse Latest Browse All 56

Trending Articles