Phaser / Pixi Normal Map Filter not working

I'm trying to apply a normal map to a Phaser sprite, but I am getting the following WebGL errors in Phaser 2.1.1 (Pixi 1.6.1):

Could not initialise shaders phaser.js:3411
WebGL: INVALID_OPERATION: useProgram: program not valid phaser.js:3475
WebGL: INVALID_OPERATION: getUniformLocation: program not linked phaser.js:3478
WebGL: INVALID_OPERATION: getAttribLocation: program not linked phaser.js:3486

      

Here is my code:

preload: function () {
  game.load.script('normal',   './js/NormalMapFilter.js');

  game.load.image('cardfront',  './img/sample-front.png');
  game.load.image('cardnormal', './img/sample-front-norm.jpg');
},

create: function() {
  this.cardfrontnorm = PIXI.Texture.fromImage('cardnormal');
  this.normalmap = new PIXI.NormalMapFilter(this.cardfrontnorm);

  this.card = game.add.sprite(game.width / 2, game.height / 2, 'cardfront');
  this.card.filters = [this.normalmap];
}

      

Both the sprite image and the normal map are 512x512.

Any help would be greatly appreciated, thanks!

+3


source to share


1 answer


Apparently NormalMapFilter was an experiment and never intended to be introduced into the library:

Check out HTML5 Game Devs - Pixijs Forum



However, you can try using the lighting plugin here: https://github.com/pixijs/pixi-lights

+1


source







All Articles