https://github.com/audulus/mslview
Shadertoy-style SwiftUI view
https://github.com/audulus/mslview
ios macos metal swiftui
Last synced: about 1 month ago
JSON representation
Shadertoy-style SwiftUI view
- Host: GitHub
- URL: https://github.com/audulus/mslview
- Owner: audulus
- License: mit
- Created: 2022-02-14T15:44:23.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-03-04T20:25:35.000Z (about 3 years ago)
- Last Synced: 2025-04-15T13:58:05.402Z (about 1 month ago)
- Topics: ios, macos, metal, swiftui
- Language: Swift
- Homepage:
- Size: 35.2 KB
- Stars: 50
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MSLView

SwiftUI view for Shadertoy-style MSL shaders
```Swift
import MSLViewstruct Constants {
var r: Float
}struct ContentView: View {
@State var constants = Constants(r: 0)
let shader = """
struct Constants {
float r;
};
fragment float4 mainImage(FragmentIn input [[stage_in]],
constant Constants& c,
constant uint2& viewSize) {
return float4(c.r,
input.position.x/viewSize.x,
input.position.y/viewSize.y,1);
}
"""var body: some View {
VStack {
MSLView(shader: shader, constants: constants)
HStack {
Slider(value: $constants.r)
Text("\(constants.r)")
}.padding()
}
}}
```