Variablur icon indicating copy to clipboard operation
Variablur copied to clipboard

VariableBlurView() by itself?

Open Saim-Khan1 opened this issue 2 years ago • 2 comments

Hey @daprice! Love this repo, been waiting for a Metal based progressive blur for a while now so thanks a lot for putting this together! Was just wondering whether it'd be possible to have a VariableBlurView() as a view itself, so it can be, for example, put on top of content in a ZStack or as an overlay instead of being applied to a view as a modifier? A bit like UIKit's UIVisualEffectView I suppose. That'd be awesome, thanks a lot :)

Saim-Khan1 avatar Nov 29 '23 21:11 Saim-Khan1

I’d love that too, but I don’t think SwiftUI currently provides a documented way for shaders to sample from layers behind a view, only from the view’s own layer.

The closest thing I can find is the ability to use a Shader as a ShapeStyle, which in theory could work similar to Apple’s built in Materials, but the shader function signature they give doesn’t pass a layer to sample from.

I hope future versions of SwiftUI expand shader functionality to allow this. 🤞

Leaving this issue open in case someone else knows of a way.

daprice avatar Nov 29 '23 23:11 daprice

Ahh I see, that's a shame. Thanks a lot for looking into it anyway, and yep fingers crossed! 🤞

Saim-Khan1 avatar Dec 08 '23 13:12 Saim-Khan1