CanvasTexture Flickering Problem

Hi,

I’ve been playing around with the Canvas Texture, one CanvasTexture 480x270 where I refresh the canvas every frame, it has blendMode multiply on it. I’m drawing a rectangle that covers the whole texture, and radial gradients on top of it of various sizes. I’m using it for a lighting effect.

It was fine for a while but all of a sudden it started flickering. It started happening when I add an extra sprite to the scene. It doesn’t seem to be related to how much I’m drawing to the canvas because I could simply draw a small rectangle and it would flicker, it’s simply because I added more sprites to the scene. Flickering only seems to happen on sprites and tilemaps, as if the blendMode isn’t affecting them every few frames. Doesn’t seem to be affecting FPS as I still get full 60.

If I remove the blendMode, flickering still occurs. But the flickering only happens on sprites and the tilemap I’m using. I do not notice any flickering occurring on the background.
The image the CanvasTexture is on is on a depth higher than all the other game objects.

Happens in both WEBGL and CANVAS modes.

I can manage to get the flickering to stop when I do various things with the camera, like panning or following. But it’s really unreliable and it seems to be luck when it manages to stop.

Does anybody have any idea how I could stop this flickering? It just seems to be weird behavior of Phaser.
Of if anyone knows of any alternatives I could use to do this lighting effect? I’m not gonna bother with Light2D as normal maps seem like too much of a hassle.

1 Like