Skip to content

Conversation

@privatestefans
Copy link
Contributor

Description of change

Blend mode filter now inherit render target's resolution, instead default to 1.
This will fix advanced blend mode like overlay, color-burn, soft-light when devicePixelRatio or the renderer’s resolution is not 1 or a power of two.

Pre-Merge Checklist
  • Tests and/or benchmarks are included
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)
Related

Blend mode filter now inherit render target's resolution, instead default to 1.
This will fix advanced blend mode like `overlay` when `devicePixelRatio` or the renderer’s resolution is not 1 or a power of two.
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jul 26, 2025

pixi.js-basepixi.js-bunny-mark

npm i https://pkg.pr.new/pixijs/pixijs/pixi.js@11584

commit: c755232

@bigtimebuddy
Copy link
Member

I'm not sure using inherit as the default filter resolution is the best fix. The underlying problem seems like a mismatch between filter and renderer resolution, which we need to support. This fix is masking that problem.

Also, would probably consider this a breaking change since it will increase memory usage unexpectedly for users. I'd, however, be open to reconsidering 1 as the default filter resolution in the next major version.

…not power of two

* move `inherit` settings to `BlendModeFilter.ts` (but commented)
@privatestefans
Copy link
Contributor Author

Thanks for the feedback!

As far as I know, if we're using inherit, it will automatically use the render target's resolution as the filter resolution.
And because BlendModeFilter does grab a snapshot of the area where it's being rendered and pass it to the shader, I think the default filter resolution should be inherit to ensure the filter matches the resolution of the captured content.

But I understand your concern, and I comes up with 2 solution:

  1. Instead of modify the default in the Filter class, we can set inherit only for BlendModeFilter. or maybe...
  2. Only change the filter resolution if the back texture resolution is not power of two. The filter texture may looks downscaled on final render, but may unnoticeable for device with high device pixel ratio and memory usage won’t be significantly impacted.

I would love to get your input on this.

@privatestefans
Copy link
Contributor Author

Playground to test:

@bigtimebuddy
Copy link
Member

The context for why we chose 1 as the default resolution instead of the renderer resolution was more about performance. Filters generally hurt runtime performance in two ways: deoptimize batching and can use a lot of memory. For Pixi, we generally set defaults that are designed to perform the best sometimes at the expensive of fidelity. This was the reasons we chose resolution: 1.

I'd like @GoodBoyDigital or @Zyie to weigh-in on this one.

@bigtimebuddy
Copy link
Member

@privatestefans Thanks for your patience here. I had a chat with the team and this is what we decided:

  • We agreed that "inherit" should be the new default resolution for all Filters. However, as it is a breaking change, we feel uncomfortable pushing this change in v8. Our next major release (currently unscheduled) we will be changing this.
  • For now, the best way to solve this is education, so we'd be in favor of telling users, maybe in the docs, that setting Filter.defaultOptions.resolution = "inherit" before creating any filters is the best way to be future-compatible.

@privatestefans
Copy link
Contributor Author

Thanks for taking the time to discuss with the team.
I understand the decision, and it sounds like a thoughtful approach.

I think for this PR, I'll revert to my original proposal so it can be merged later or for future reference.

Apologies for the delayed response 😅

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

Successfully merging this pull request may close these issues.

Bug: Advanced blend modes don't adjust to renderer resolution / window pixel ratio

2 participants