Live data from Hacker News

Next-level frosted glass with backdrop-filter

joshwcomeau.com

11–20 of 67 posts

Re: Next-level frosted glass with backdrop-filter

#11

How does this compare with this that was posted on HN a few weeks ago? https://www.tyleo.com/html-glass.html

That one suffers from the effect described in the article, it only considers pixels directly behind the element for blurring. So unlike real glass it can't catch adjacent light.

But it is unique in its own way and has many other good ideas.

Re: Next-level frosted glass with backdrop-filter

#12
In case anyone's trying to remember what macos/iOS does with what they call 'vibrancy' - can't find the video directly anymore but they sorta touch on it here (WWDC 2014 , session 220): https://github.com/ASCIIwwdc/wwdc-session-transcripts/blob/b... "The actual implementation and blending that we do could be a Linear Burn, a Color Dodge, PlusD, PlusL."

Re: Next-level frosted glass with backdrop-filter

#13
I don’t like the `height: 200%`: you might as well be specific about how much extra you need, because an extra 100% might be a lot more than you need, or not enough.

First question: how much more do you need? Per https://drafts.fxtf.org/filter-effects/#funcdef-filter-blur (via MDN blur() docs → link to spec):

> Note: A true Gaussian blur has theoretically infinite extent, but in practice all implementations use a finite-area approximation of a Gaussian blur. At the time of writing (January 2024) all major implementations use the familiar three-pass box blur approximation, which has extent: ((3 * sqrt(2 * π) / 4) * σ).

¾√2π is about 1.88; it’s generally most convenient to just double the radius instead.

So, if you’re going for a 16px blur, add 32px. (The formula would make it 30.079px; so I’d accept 30px and 31px also.)

In the first main demo with code: ditch the `height: 200%`, change the inset to `0 0 -32px 0`, and change the 50% in the mask-image linear-gradient to calc(100% - 32px). (Aside: you can also shorten the gradient definition: linear-gradient(to bottom, black calc(100% - 32px), transparent 0%).) Applying it to later things is left as an exercise to the reader.

The SVG element is interesting in this rendering size question: it lets you control the rendering area for the filter, via its x, y, width and height attributes. Their defaults are -10%, -10%, 120% and 120%, meaning 10% overdraw on each edge. Unfortunately you can’t really do height="calc(100% + 32px)" which is what you’d want for the equivalent here. Yes, you could definitely do this whole thing in SVG, using the BackgroundImage source—in fact, you can do better, because you can composite that with SourceAlpha, rather than the dodgy mask-image technique you’re limited to in HTML/CSS. Unfortunately I don’t believe any current browsers support BackgroundImage, though I think IE and Opera used to, and Inkscape does.

Re: Next-level frosted glass with backdrop-filter

#14

In case anyone's trying to remember what macos/iOS does with what they call 'vibrancy' - can't find the video directly anymore but they sorta touch on it here (WWDC 2014 , session 220): https://github.com/ASCIIwwdc/wwdc-session-transcripts/blob/b... "The actual implementation and blending that we do could be a Linear Burn, a Color Dodge, PlusD, PlusL."

Microsoft’s Acrylic is tolerably documented too (the concepts, not the exact values): https://learn.microsoft.com/en-us/windows/apps/design/style/.... At the end, especially: “The acrylic recipe: background, blur, exclusion blend, color/tint overlay, noise.”

Re: Next-level frosted glass with backdrop-filter

#17
This is claptrap: "This effect helps us add depth and realism to our projects." -- when was the last time you, dear reader, saw frosted glass? Let's be real: it's because it was in iOS 7, Apple never moved on from that look and feel, and Apple is Apple. (n.b. a winking opinion, and a mild homage to Apple lore, not a genuine rebuke: https://folklore.org/Round_Rects_Are_Everywhere.html)

Re: Next-level frosted glass with backdrop-filter

#20

I don’t like the `height: 200%`: you might as well be specific about how much extra you need, because an extra 100% might be a lot more than you need, or not enough. First question: how much more do you need? Per https://drafts.fxtf.org/filter-effects/#funcdef-filter-blur (via MDN blur() docs → link to spec): > Note: A true Gaussian blur has theoretically infinite extent, but in practice all implementations use a fin…

All this time I thought a 16px gaussian blur meant it faded to 0 at 16px. That explains why I always seem to need to add some extra padding! I never thought to question it! Wow! I can use this right away to fix some stuff, thanks for sharing!
Post reply on HN