News for hackers. Stuff that matters.
Re:Shadow Palette Generator by londons_explore on Wednesday November 17, 2021 @04:07AM (#29250573)
Shadows are computationally expensive to generate. First the object has to be rendered to a buffer, and then the buffer blurred, and then the blurred buffer, object and background composited together.

Having many shadows on an object makes this path much longer. I can imagine adding this to a page could easily run out of GPU RAM and end up having to discard buffers which later need to be re-rendered.

End result:. Hot slow phone.

I'd like to at least see a benchmark of this effect before suggesting multiple box shadows.

Re:Shadow Palette Generator by tobr on Wednesday November 17, 2021 @06:17AM (#29251515)
That’s not how CSS box shadows are generated. They only need to take into account the dimensions of the rectangle and the corner radius, which opens up for a lot of optimization.
Re:Shadow Palette Generator by londons_explore on Wednesday November 17, 2021 @07:27AM (#29252167)
Take a look at the layer tree in the overflow menu in the chrome devtools. You can see which shadows had to be rendered to a buffer and which did not.

I suspect the complexity is that some objects can be transparent, and then their shadows get complex.

Re:Shadow Palette Generator by tobr on Wednesday November 17, 2021 @08:04AM (#29252470)
If you have an example of how transparency makes the shadow more complex, please give it. I’m fairly confident there are no cases like that. Transparency in the background image or border doesn’t change the shape of the box the shadow applies to, and things like opacity affects the shadow too. The example you had in your first comment is also wrong, as shadows don’t apply to other shadows.

There might still be cases where a particular optimization doesn’t work and the browser falls back to a buffer.

Re:Shadow Palette Generator by jonwinstanley on Wednesday November 17, 2021 @04:34AM (#29250772)
I agree that a benchmark on CPU/GPU would be helpful for this effect. However, I doubt you'd end up running out of ram through using this technique unless it was added to a large number of elements.
Re:Shadow Palette Generator by MrLeap on Wednesday November 17, 2021 @05:46AM (#29251310)
Makes me wish the css filter feature hadn't fizzled. Would be much more performant to do this in a single pass by giving a gradient to a box distance formula in a shader!
Re:Shadow Palette Generator by user-the-name on Wednesday November 17, 2021 @06:23AM (#29251564)
That will not generate a visually pleasing shadow, though.
Re:Shadow Palette Generator by extropy on Wednesday November 17, 2021 @07:31AM (#29252200)
Because? You could specify any formula you want. Including lookup tables. If you can describe it, the shader can render it.
Re:Shadow Palette Generator by user-the-name on Wednesday November 17, 2021 @07:41AM (#29252283)
Because a visually pleasing shadow does not follow a box distance function at all.