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

Bitmapmask distort image while resizing canvas #6527

Closed
rexrainbow opened this issue Jun 16, 2023 · 5 comments
Closed

Bitmapmask distort image while resizing canvas #6527

rexrainbow opened this issue Jun 16, 2023 · 5 comments

Comments

@rexrainbow
Copy link
Contributor

Version

  • Phaser Version: 3.60.0
  • Operating system: window 10
  • Browser: Chrome/FF

Description

Apply bitmap mask to a layer, then resize game canvas. The render result is not correct.

Example Test Code

Test code

  • Rectangle game objects will resize according to current window width.
  • Resize browser window to see the render result
  • Comment line 24 can disable bitmap mask applying

Additional Information

This issue is similar with #6503

@Arcturous
Copy link

Don't know if its related but it also happens when I use Rex's KawaseBlur shader.

@rexrainbow
Copy link
Contributor Author

@Arcturous Yes, it is related.

photonstorm added a commit that referenced this issue Sep 7, 2023
…s `RenderTarget` instances. This fixes an issue where the `PostFXPipeline` would not resize the render targets when the game size changed, causing them to become out of sync with the game canvas. Fix #6503 #6527
@photonstorm
Copy link
Collaborator

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.

@pavels
Copy link

pavels commented Sep 10, 2023

Hi

i tried against current master and unfortunately it is not fixed

Also tried with https://labs.phaser.io/edit.html?src=src/game%20objects/render%20texture/render%20texture%20as%20a%20mask.js&v=dev

Following code:

class Example extends Phaser.Scene
{
    preload ()
    {
        this.load.image('brush', 'assets/sprites/brush1.png');
        this.load.image('pic', 'assets/pics/brilliance-jim-sachs.png');
    }

    create ()
    {
        this.game.scale.resize(800, 600);
        
        const rt = this.add.renderTexture(400, 300, 800, 600);

        const mask = rt.createBitmapMask();

        const pic = this.add.image(400, 300, 'pic');

        pic.setMask(mask);

        this.input.on('pointermove', pointer =>
        {

            if (pointer.isDown)
            {
                rt.draw('brush', pointer.x - 32, pointer.y - 32);
            }

        }, this);

        this.input.keyboard.on('keydown-SPACE', event =>
        {

            rt.resize(400, 300);

        });
    }
}

const config = {
    type: Phaser.AUTO,
    parent: 'phaser-example',
    width: 400,
    height: 300,
    scene: Example
};

const game = new Phaser.Game(config);

And it is broken as well

@martonkaufmann
Copy link

Hi

i tried against current master and unfortunately it is not fixed

Also tried with https://labs.phaser.io/edit.html?src=src/game%20objects/render%20texture/render%20texture%20as%20a%20mask.js&v=dev

Following code:

class Example extends Phaser.Scene
{
    preload ()
    {
        this.load.image('brush', 'assets/sprites/brush1.png');
        this.load.image('pic', 'assets/pics/brilliance-jim-sachs.png');
    }

    create ()
    {
        this.game.scale.resize(800, 600);
        
        const rt = this.add.renderTexture(400, 300, 800, 600);

        const mask = rt.createBitmapMask();

        const pic = this.add.image(400, 300, 'pic');

        pic.setMask(mask);

        this.input.on('pointermove', pointer =>
        {

            if (pointer.isDown)
            {
                rt.draw('brush', pointer.x - 32, pointer.y - 32);
            }

        }, this);

        this.input.keyboard.on('keydown-SPACE', event =>
        {

            rt.resize(400, 300);

        });
    }
}

const config = {
    type: Phaser.AUTO,
    parent: 'phaser-example',
    width: 400,
    height: 300,
    scene: Example
};

const game = new Phaser.Game(config);

And it is broken as well

The example is completely broken with the link you provided. I also experience the same on my project when i try the latest beta.

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

No branches or pull requests

5 participants