Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to blur() consistently cross browsers?

There is a difference in rendering of blur effect in Firefox and Chrome.

For some small value like filter: blur(30px) Chrome and Firefox produce nearly the same Gaussian blur.

But for a big value like filter: blur(200px) those browsers have a very noticeable difference.

Here is an example of that in 4 images: (FF left, Chrome right)

(Website shown is https://developer.mozilla.org/en-US/docs/Web/CSS/filter-function I edited maximum of slider to be 200 in devtools)

0px blur: same

zero blur

30px blur: same

thirty blur

100px blur: same-ish

hundred blur

200px blur: different

two hundred blur

It looks as if Firefox applies blur only inside the original dimensions, whereas Chrome enlarges the blur application area and leaks the "whiteness" from outside to inside. That observation may be wrong though.

My question to SO is "How can I get a consistent blur effect cross browsers?"

like image 268
alpersunter Avatar asked Oct 16 '25 11:10

alpersunter


1 Answers

Firefox limits the css blur filter to 100dp (device pixels) or 300px depending on if it is applied via hardware or software rendering which depends on the hardware of the user. This is because of the performance impact the gaussian blur effect has. More info: https://bugzilla.mozilla.org/show_bug.cgi?id=1530810

Chrome has a limit as well, I think it is 500px.

However if you want to go over that limit and ignore any performance problems you can implement a gaussian blur effect within a canvas element. Via for example this WebGL shader: https://github.com/Jam3/glsl-fast-gaussian-blur That'll get you a consisent look regardless of the performance impact.

like image 120
Wezelkrozum Avatar answered Oct 18 '25 00:10

Wezelkrozum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!