daprice / Variablur

Variable blur effects for SwiftUI, powered by Metal
https://swiftpackageindex.com/daprice/Variablur
MIT License
200 stars 2 forks source link

VariableBlurView() by itself? #1

Open Saim-Khan1 opened 11 months ago

Saim-Khan1 commented 11 months ago

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 :)

daprice commented 11 months ago

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.

Saim-Khan1 commented 10 months ago

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