summaryrefslogtreecommitdiff
path: root/src/shaders/math
diff options
context:
space:
mode:
Diffstat (limited to 'src/shaders/math')
-rw-r--r--src/shaders/math/color_c64.wgsl15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/shaders/math/color_c64.wgsl b/src/shaders/math/color_c64.wgsl
index ef8f073..e1b142e 100644
--- a/src/shaders/math/color_c64.wgsl
+++ b/src/shaders/math/color_c64.wgsl
@@ -1,6 +1,6 @@
-// C64 palette and ordered-dither quantization.
-// Provides Dither() to snap any RGBA color to the nearest C64 color pair
-// via 8x8 Bayer threshold, suitable for NTSC and retro post-process effects.
+// C64 palette, ordered-dither quantization, and border color animation.
+// Provides Dither() and get_border_c64() for NTSC and retro post-process effects.
+#include "math/noise"
const NUM_COLORS : u32 = 16;
const C64Colors = array<vec3f, NUM_COLORS>(
@@ -81,3 +81,12 @@ fn Dither(col: vec4f, uv: vec2f, xsize: f32, ysize: f32) -> vec4f {
color = mix(c1, c2, f32(frac > thresh));
return sqrt(color);
}
+
+// Animated C64 border color: cycles through palette driven by beat_time.
+// ysize: virtual scanline count (e.g. 33.*8.), matching the pixel grid.
+fn get_border_c64(uv: vec2f, beat_time: f32, ysize: f32) -> vec4f {
+ let offset = uv.x + ysize * uv.y / 8.;
+ let phase = 3. * round(hash_1f(beat_time * 533.) * 24.);
+ let id = round(hash_1f(round(sin(beat_time * 1.6) + offset + phase)) * 8.);
+ return vec4f(C64Colors[u32(id)], 1.);
+}