phaser icon indicating copy to clipboard operation
phaser copied to clipboard

First frame of PostFX pipeline displays glitches

Open moufmouf opened this issue 2 years ago • 4 comments

Version

  • Phaser Version: 3.70
  • Operating system: Ubuntu 23.10
  • Browser: Mostly visible on Chrome.

Description

When applying an effect to a sprite, the very first frame of the game has glitches. It seems to happen whatever the Postfx pipeline applied we use.

The glitch can be hard to spot because it happens only on the first frame.

Example Test Code

To make the issue easier to see, I wrote a program that adds a postfx pipeline on a sprite, then removes it, then adds it back, etc... On each frame, I'm switching the effect on and off.

https://codepen.io/moufmouf/pen/abXjYRV

(Note: test this in Chrome)

The program works flawlessly with Phaser 3.60, but has glitches in Phaser 3.70.

Additional Information

The issue was first spotted on the Rex pipelines and an issue is opened there: https://github.com/rexrainbow/phaser3-rex-notes/issues/395 However, it seems more likely the issue is related to Phaser. My guess is that it is linked to the fact the creation of the effect is now delayed until its boot method, but I have no proof of that.

// @rexrainbow @LaP0573 @tongliang999

Let me know if I can do anything to help.

moufmouf avatar Nov 28 '23 07:11 moufmouf

Might replace my outline-postfx effect by built-in postfx effect, like shadow effect , to discard affect from 3rd party plugin.

  • Add built-in shadow effect : var effect = gameObject.postFX.addShadow(10, -10, 0.006, 1, 0xff0000, 10)
  • Remove effect : gameObject.preFX.remove(effect)

BTW, I can't reproduce this render result in my environment :

  • os : window 11
  • browser : chrome, firedox

rexrainbow avatar Nov 28 '23 08:11 rexrainbow

I rewrote the codepen to use the built in effect (addShadow) as suggested by @rexrainbow . The codepen now only uses Phaser 3.70 and has no dependencies on Rex plugins

https://codepen.io/moufmouf/pen/abXjYRV

Here is what I see:

Capture vidéo du 2023-11-28 10-40-13.webm

moufmouf avatar Nov 28 '23 09:11 moufmouf

I rewrote the codepen to use the built in effect (addShadow) as suggested by @rexrainbow . The codepen now only uses Phaser 3.70 and has no dependencies on Rex plugins

https://codepen.io/moufmouf/pen/abXjYRV

Here is what I see:

Capture.video.du.2023-11-28.10-40-13.webm

I experienced similar issues, but on mobile devices using rex's shader-hsladjust

btw video example of above codepen

https://github.com/photonstorm/phaser/assets/42466730/df55bc95-6721-430c-87ec-3119354b77cf

ddanushkin avatar Nov 28 '23 20:11 ddanushkin

@ddanushkin It is because that I use built-in postfx pipeline as base class. You can try this workaround solution provided by @tongliang999

rexrainbow avatar Nov 29 '23 04:11 rexrainbow

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.

photonstorm avatar Jan 31 '24 20:01 photonstorm

Hey @photonstorm !

Thanks a lot for looking into this. I just tested the master branch and I can confirm your fix works correctly.

As expected from the fix, the shader is not displayed on the next frame after being added, but from the second frame onwards, everything works like a charm. :+1:

moufmouf avatar Jan 31 '24 20:01 moufmouf