Skip to content

[4.0.0-rc.5] Blend mode applied to masked sibling #7201

Closed

Description

@leemanhopeter

Version

  • Phaser Version: 4.0.0-rc.5

Description

If a game object inside a container has a blend mode, it will also become the blend mode of the sibling

Example Test Code

https://phaser.io/sandbox/6o5q1YA7

You can see that the green rectangle also has ADD blend mode which should only be applied to the red rectangle.

Note that if the red rectangle is added last, then this error will not occur.

Note also that if subContainer is not masked, or if the mask is not on subContainer but on the green rectangle, then this error will also not occur.

Activity

  1. imsarang commented on Oct 19, 2025

    @imsarang

    Hi, I want to contribute to this project. Can you tell me which file needs to be changed, or should i just do the changes in the example code above

  2. added a commit that references this issue on Dec 19, 2025
    6f5c7a1
  3. BenjaminDRichards commented on Dec 19, 2025

    @BenjaminDRichards
    Collaborator

    This was a tricky one. It required some digging into the render system. (I'm sorry, not a great issue for beginners, unless you're keen on doing that digging too!)

    It turns out there was a longstanding issue with the Container rendering code. Containers can have a blend mode of SKIP_CHECK, which lets their children set the blend mode. Ordinarily, a second child will set its own blend mode. But if that child is also a Container with SKIP_CHECK, it will just carry on with whatever the last object's blend mode was. Again, ordinarily, the second container's children will set their own blend modes, and everything will be fine.

    But when there's a filter or mask involved, an extra step is added, and it uses the blend mode from above. So the dangling blend mode from the outer Container is used to blend the results of the mask. All the internal parts of the inner Container are rendered correctly, but they are then composited with that erroneous ADD mode.

    I've changed the logic to be more explicit about setting a blend mode in the Container. It now tracks a base drawing context, which it can fall back to if it can't find a definite blend mode. This resolves the issue, and will be in the next release.

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

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions