Issue when using Masks and Lights (pipeline "Light2d")

Hi everyone,

I run into a problem when using masks on sprites and at the same time using lights on (other unrelated) sprites.

As an example take this lab:

http://labs.phaser.io/edit.html?src=src\game%20objects\lights\bitmap%20text%20light.js

if you add the following four lines (a partly masked sprite not related to anything) at the start of the create function, the bitmap text is gone.

var mySprite = this.add.sprite(100, 100, 'sonic');
var myMask = this.add.rectangle(100, 100, 50, 50, 0xFFFFFF);
myMask.visible = false;
mySprite.mask = new Phaser.Display.Masks.BitmapMask(this, myMask);

Working original (without the masked sprite):

Broken, with the masked sprite:

In my actual game masking parts of the ui (for health bars) breaks lights on a dynamic tilemap layer.
I am guessing that this is related to what is happening here.

Am I doing something wrong in my masking, or is “Light2d” just not usable with masks at all?

I noticed, that the effect does not happen, when the masked sprite is “in front” the Light2d Sprite. So maybe something in the rendering does not get reset correctly?

Lights are quite unstable in the current version of Phaser 3 and were even deprecated at one point. The next release, which is currently in beta, fixes a lot of problems with lights. Your example appears to work correctly in the dev version.

1 Like

Thank you for this information.
I’ll check if the beta also resolves my initial problem. :slight_smile: