3

我正在尝试将法线贴图应用于 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。

任何帮助将不胜感激,谢谢!

4

1 回答 1

1

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

检查 HTML5 Game Devs - Pixijs 论坛

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

于 2015-07-28T20:59:54.777 回答