You can use this effect to produce a decorative/ornamental glass-like effect on top of your SwiftUI View
s 🔍. The package features an example app that can be used to play with some input parameters and showcases a bunch of normal textures.
It models refraction and reflection of light taking the fresnel effect into account. It also allows one to calculate a "detail" that serves as a visual clue about the shape of the glass.
Be sure to check it in both light and dark mode (especially if you're after reflections ✨).
Use as a Swift Package.
Use a View.glassEffect
modifier. At a minimum, you should be able to run the effect by supplying a normal map texture image. For best results, be sure to use high-quality normal maps.
I used a bunch of resources from 3dtextures.me and everytexture.com in the example app.
I made it mostly for myself as an exercise in my recent SwiftUI
+ Metal
research.
Feel free to use it, feel free to contribute (fix issues, share ideas), and feel free to hit me up @czajnikowski 👋