Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/czajnikowski/glasseffect
SwiftUI + Metal effect that allows to reproduce see-through, decorative/ornamental glass-like effects.
https://github.com/czajnikowski/glasseffect
effects ios17 macos14 metal metalapi rendering swift swift-package swift-package-manager swiftui
Last synced: about 2 months ago
JSON representation
SwiftUI + Metal effect that allows to reproduce see-through, decorative/ornamental glass-like effects.
- Host: GitHub
- URL: https://github.com/czajnikowski/glasseffect
- Owner: Czajnikowski
- License: mit
- Created: 2024-02-28T08:05:59.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-22T11:43:53.000Z (10 months ago)
- Last Synced: 2024-10-30T17:26:43.643Z (2 months ago)
- Topics: effects, ios17, macos14, metal, metalapi, rendering, swift, swift-package, swift-package-manager, swiftui
- Language: Swift
- Homepage:
- Size: 4.38 MB
- Stars: 11
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GlassEffect
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.
![output](https://github.com/Czajnikowski/GlassEffect/assets/973682/1a8ab0eb-736e-41d3-929b-74730fa9864a)
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](https://github.com/Czajnikowski/GlassEffect/blob/main/Sources/GlassEffect/GlassEffect.swift#L5-L24). 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](https://3dtextures.me) and [everytexture.com](https://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](https://twitter.com/czajnikowski) 👋