Skip to content

Odd-dimensioned mask filter texture isn't cleared #7102

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

Closed
samme opened this issue Apr 6, 2025 · 1 comment
Closed

Odd-dimensioned mask filter texture isn't cleared #7102

samme opened this issue Apr 6, 2025 · 1 comment
Assignees
Labels

Comments

@samme
Copy link
Contributor

samme commented Apr 6, 2025

Version

  • Phaser Version: 4.0.0 RC 1

Description

I created a mask filter from a game object and applied it to a sprite (205x300), internal context, then tweened the mask source game object's scale.

The mask seems to render correctly at first but then stops updating.

Example Test Code

https://phaser.io/sandbox/jSwQ4Uzc

Additional Information

updateDynamicTexture() is calling _dynamicTexture.setSize() every frame, but _dynamicTexture isn't being cleared.

Removing forceEven = true in _dynamicTexture.setSize() eliminates the problem.

BenjaminDRichards added a commit that referenced this issue Apr 8, 2025
This fixes #7102 where an odd-sized object's Mask filter won't clear.
@BenjaminDRichards
Copy link
Collaborator

This is happening because the forceEven behavior is true by default. The DynamicTexture wants to resize just once, to the correct size; but it is never allowed to do so, because the target size is not even.

I fixed the issue by instructing the Mask to create its DynamicTexture with forceEven = false. This allows it to complete the resize.

I also added extra parameters to TextureManager#addDynamicTexture for handling forceEven.

Thanks for digging up this one! It was just a case of putting false somewhere in the code, as you identified, but there were a lot of places it could have gone. Mask texture size was the correct place, as a mask may be applied to any resolution of object.

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

No branches or pull requests

3 participants