/GlassEffect

SwiftUI + Metal effect that allows to reproduce see-through, decorative/ornamental glass-like effects.

Primary LanguageSwiftMIT LicenseMIT

GlassEffect

You can use this effect to produce a decorative/ornamental glass-like effect on top of your SwiftUI Views 🔍. 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.

output

Be sure to check it in both light and dark mode (especially if you're after reflections ✨).

How To Use It?

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.

Credits

I used a bunch of resources from 3dtextures.me and everytexture.com in the example app.

Why?

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 👋