diff options
author | davidovski <david@davidovski.xyz> | 2024-04-21 21:23:21 +0100 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2024-04-21 21:23:21 +0100 |
commit | 2d6d9f97093544e0d2faccc94f3b8bf369c03819 (patch) | |
tree | cab6b58d90a066b743764dfa91fcabfc87e9ba0e /shaders | |
parent | 64757d18c4b2669c46f2dc88293cf2f0ea1887db (diff) |
add placing objects
Diffstat (limited to 'shaders')
-rw-r--r-- | shaders/none.kage | 12 | ||||
-rw-r--r-- | shaders/vcr.kage | 44 |
2 files changed, 56 insertions, 0 deletions
diff --git a/shaders/none.kage b/shaders/none.kage new file mode 100644 index 0000000..3eccc50 --- /dev/null +++ b/shaders/none.kage @@ -0,0 +1,12 @@ +//go:build ignore + +//kage:unit pixels + +package main + +var Time float +var Cursor vec2 + +func Fragment(dstPos vec4, srcPos vec2, color vec4) vec4 { + return imageSrc2UnsafeAt(srcPos); +} 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); + } + +} |