Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/audulus/mslview

Shadertoy-style SwiftUI view
https://github.com/audulus/mslview

ios macos metal swiftui

Last synced: 3 months ago
JSON representation

Shadertoy-style SwiftUI view

Awesome Lists containing this project

README

        

# MSLView

![build status](https://github.com/audulus/MSLView/actions/workflows/build.yml/badge.svg)
Swift Package Manager (SPM) compatible

SwiftUI view for Shadertoy-style MSL shaders

```Swift
import MSLView

struct 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()
}
}

}
```