summaryrefslogtreecommitdiff
path: root/shaders/vcr.kage
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2024-04-21 21:23:21 +0100
committerdavidovski <david@davidovski.xyz>2024-04-21 21:23:21 +0100
commit2d6d9f97093544e0d2faccc94f3b8bf369c03819 (patch)
treecab6b58d90a066b743764dfa91fcabfc87e9ba0e /shaders/vcr.kage
parent64757d18c4b2669c46f2dc88293cf2f0ea1887db (diff)
add placing objects
Diffstat (limited to 'shaders/vcr.kage')
-rw-r--r--shaders/vcr.kage44
1 files changed, 44 insertions, 0 deletions
diff --git a/shaders/vcr.kage b/shaders/vcr.kage
new file mode 100644
index 0000000..3bee5cd
--- /dev/null
+++ b/shaders/vcr.kage
@@ -0,0 +1,44 @@
+//go:build ignore
+
+//kage:unit pixels
+
+package main
+
+var Time float
+var Cursor vec2
+
+const noiseX = 80.0
+const noiseY = 100.0
+
+const colorOffsetIntensity = 1.2
+
+func rand(co vec2) float {
+ return fract(sin(dot(co.xy, vec2(12.9898,78.233))) * 43758.5453);
+}
+
+func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 {
+ noiseOffset := Time / 7
+ col := vec4(0)
+ uv := srcPos / imageSrc0Size()
+
+ uv.x = uv.x + (rand(vec2(Time,srcPos.y)) - 0.5) / (noiseX);
+ uv.y = uv.y + (rand(vec2(Time))-0.5) / (noiseY);
+
+ whiteNoise := rand(vec2(floor(uv.y*80.0),floor(uv.x*50.0))+vec2(Time,0))
+ off := 1.0 - mod(uv.y - noiseOffset, 1)
+
+ if (whiteNoise > 11.5-30.0*(off)) || whiteNoise < 1.5-2.0*(off) {
+ // Sample the texture.
+
+ offsetR := vec2(0.006 * sin(Time), 0.0) * colorOffsetIntensity;
+ offsetG := vec2(0.0073 * (cos(Time * 0.97)), 0.0) * colorOffsetIntensity;
+ r := imageSrc0UnsafeAt((uv+offsetR) * imageSrc0Size()).r
+ g := imageSrc0UnsafeAt((uv+offsetG) * imageSrc0Size()).g
+ b := imageSrc0UnsafeAt(uv * imageSrc0Size()).b
+ return vec4(r, g, b, 1.0)
+ } else {
+ col = imageSrc2UnsafeAt(uv * imageSrc0Size());
+ return col + vec4(0.8);
+ }
+
+}