Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

UlyssesZh
Copy link
Contributor

Closes #11554.

Description of change

Fix blur filter strength and deprecate old behavior. The old behavior is still the default, and the new behavior is enabled by setting the static property BlurFilterPass.sqrtScaledStrength = true. Creating an instance of BlurFilterPass without this flag emits a deprecation warning.

Core change:

-this._uniforms.uStrength = this.strength / this.passes;
+this._uniforms.uStrength = this.strength / Math.sqrt(this.passes * (this._kernelSize - 1));

Now the standard deviation of the blurring effect is independent of the quality (number of passes) and the kernel size. The distribution defined in constant GAUSSIAN_VALUES_FIX has standard deviation sqrt(kernelSize - 1).

Not sure if a visual scene test should be included.

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

@Zyie Zyie changed the title fix blur filter strength and deprecate old behavior fix: blur filter strength and deprecate old behavior Jul 24, 2025
Copy link

pkg-pr-new bot commented Jul 24, 2025

pixi.js-basepixi.js-bunny-mark

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

commit: dfac4e8

Copy link
Member

@GoodBoyDigital GoodBoyDigital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is great, thanks so much for the fix.
One thing i would suggest is we make BlurPass 'dumb' to the deprication and instead pass in the param at construction eg '


new BlurPass({..., sqrtScaledStrength})

This would remove the need for any static variables on it.

We can the add a param to BlurFilterOptions and BlurFilter.defaultOptions.

static defaultOptions = {
    ...,
    sqrtScaledStrength:true
}

we can then do a deprication check in the BlurFilter. The main reason for this is users do not tend to use or know about BlurFilterPass class and tend to work with the BLurFilter class only.

Let me know if this makes sense! Thanks!

@UlyssesZh
Copy link
Contributor Author

I used static variable because it may be burdensome for project developers to add an additional option to each blur filter instance. What about using a static property of BlurFilter instead of BlurFilterPass?

@bigtimebuddy
Copy link
Member

bigtimebuddy commented Aug 22, 2025

I agree with @UlyssesZh. A static option for deprecation is better because it means removing one line of code from your project at the next major release instead of tracking down all instances of BlurFilter.

BlurFilter seems like a better location than the more internal BlurFilterPass.

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: Implementation of BlurFilter.quality is wrong
3 participants