I've noticed problems with tilemap dynamic layer and sprites when I enable light:
Here is an example code, which you can copy to the labs.phaser.io and run:
var config = {
type: Phaser.AUTO,
width: 800,
height: 600,
parent: 'phaser-example',
backgroundColor: '#333333',
scene: {
preload: preload,
create: create,
update: update
}
};
var light;
var player;
var layer;
var game = new Phaser.Game(config);
function preload ()
{
this.load.image('tiles', [ 'assets/tilemaps/tiles/drawtiles1.png', 'assets/tilemaps/tiles/drawtiles1_n.png' ]);
this.load.spritesheet('dude', ['src/games/firstgame/assets/dude.png', 'src/games/firstgame/assets/dude.png'], { frameWidth: 32, frameHeight: 48 });
this.load.tilemapCSV('map', 'assets/tilemaps/csv/grid.csv');
}
function create ()
{
var map = this.make.tilemap({ key: 'map', tileWidth: 32, tileHeight: 32 });
var tileset = map.addTilesetImage('tiles', null, 32, 32, 1, 2);
layer = map.createDynamicLayer(0, tileset, 0, 0);
player = this.add.sprite(48, 40, 'dude');
player.setPipeline('Light2D');
layer.setPipeline('Light2D');
this.lights.enable().setAmbientColor(0xffffff);
this.lights.addLight(48, 40, 100).setColor(0xff0000).setIntensity(3.0);
}
function update (){}
Javascript error in the console:
WebGLPipeline.js:345 WebGL: INVALID_VALUE: disableVertexAttribArray: index out of range
In Firefox ESR (v52.9) error's description is a little more informative:
Error: WebGL warning: disableVertexAttribArray: -1 is not a valid `index`. This value probably comes from a getAttribLocation() call, where this return value -1 means that the passed name didn't correspond to an active attribute in the specified program.
In Firefox 61 sprite is visible, but no light. No related errors in the console.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Having looked at this, the error is nothing to do with the tilemap, it's just to do with the fact that load.spritesheet doesn't support normal maps. If you swap it for an image or an atlas it'll work fine.
Sorry to bother you. Will load.spritesheet support normal maps in the future or it is not expected to?
Yes, but not in 3.16.
Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.
This issue has been mentioned on Phaser. There might be relevant details there:
https://phaser.discourse.group/t/normal-maps-with-spritesheets-and-phaser-3-5/7503/1
Most helpful comment
Yes, but not in 3.16.