Phaser / Pixi法线贴图过滤器不起作用

时间:2014-09-19 21:58:10

标签: javascript webgl phaser-framework pixi.js

我试图将法线贴图应用于Phaser精灵,但我在Phaser 2.1.1(Pixi 1.6.1)中遇到以下WebGL错误:

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

这是我的代码:

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];
}

精灵图像和法线贴图都是512x512。

非常感谢任何帮助,谢谢!

1 个答案:

答案 0 :(得分:1)

显然,NormalMapFilter是一个实验,从未打算引入该库:

Check HTML5 Game Devs - Pixijs forum

但是,您可以尝试使用插件进行照明: https://github.com/pixijs/pixi-lights