Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preFX getting ruined by a rectangle in the same batch #6995

Open
CrispMind opened this issue Dec 24, 2024 · 0 comments
Open

preFX getting ruined by a rectangle in the same batch #6995

CrispMind opened this issue Dec 24, 2024 · 0 comments

Comments

@CrispMind
Copy link

Version

  • Phaser Version: v3.87
  • Operating system: Android 14
  • Browser: Doesn't seem to be browser specific

Description

Having FX applied to .preFX of a sprite or a text game object while also having a filled rectangle game object in the scene results in the game object with the preFX applied having broken visuals:

Screenshot_20241224_190037_Chrome

This doesn't happen in Chrome on a Windows 10 PC but is a stable repro in Chrome on Samsung S23 for me, which might be specific to how the renderer batches output, please see ## Additional Information ## below.

Example Test Code

import { Scene } from "phaser";

export class Preloader extends Scene
{
    constructor()
    {
        super( 'Preloader' );
    }
    create()
    {
        let text = this.add.text( 512, 325, 'TEST TEXT', { fontFamily: 'Arial', fontSize: 48, color: '#808080' } );
        text.preFX?.addShine();

        this.add.rectangle( 512, 640, 800, 20, 0xffffff, 0.2 );
    }
}

Additional Information

My thinking is that the rectangle and the game objects having .preFX are somehow merged into the same batch and the rectangle rebinds the texture. That is, in FXShine-frag.js:

vec4 tex = texture2D(uMainSampler, outTexCoord)

The value of 'tex' matches whatever the color of the filled rectangle was.

Looking at MultiPipeline.js, batchFillRect() makes this call at the end:

this.batchQuad(null, quad[0], quad[1], quad[2], quad[3], quad[4], quad[5], quad[6], quad[7], 0, 0, 1, 1, tint.TL, tint.TR, tint.BL, tint.BR, 2);

and that specifies no texture, which setTexture2D() replaces with this.renderer.whiteTexture, hence the result?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant