okay actually got scanlines

but fucked it over when applying it to the app
This commit is contained in:
neon443
2025-08-25 21:04:45 +01:00
parent 9e95f63494
commit 3f7f253f63
2 changed files with 102 additions and 78 deletions

View File

@@ -9,6 +9,18 @@
#include <SwiftUI/SwiftUI_Metal.h>
using namespace metal;
[[ stitchable ]] half4 crt(float2 pos, half4 color, float2 size, float time) {
float2 uv = pos/size;
// scanwave
half3 newCol = 0.75 + 0.5 + 0.5 * sin(time + uv.y*10 + half3(0));
//scanlines
newCol *= 0.5 + 0.5 * sin(uv.y * 1000.0 + half3(0));
half4 output = half4(color.xyz*newCol, 1);
return output;
}
//learning shaders stuff here
[[ stitchable ]] half4 sinebow(float2 pos, half4 color, float2 size, float time) {
float2 uv = (pos/size.x) * 2.0 - 1.0;

View File

@@ -12,7 +12,11 @@ struct ContentView: View {
@ObservedObject var hostsManager: HostsManager
@ObservedObject var keyManager: KeyManager
@State private var spawnTime: Date = .now
var body: some View {
TimelineView(.animation) { tl in
let time = tl.date.distance(to: spawnTime)
NavigationStack {
ZStack {
hostsManager.selectedTheme.background.suiColor.opacity(0.7)
@@ -98,6 +102,14 @@ struct ContentView: View {
}
}
}
.visualEffect { content, proxy in
content
.colorEffect(ShaderLibrary.crt(
.float2(proxy.size),
.float(time)
))
}
}
}
}