diff options
| author | skal <pascal.massimino@gmail.com> | 2026-03-09 08:50:52 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-03-09 08:50:52 +0100 |
| commit | 7e7615075b666bfaec5f07f727da85c724b64399 (patch) | |
| tree | e5c64a729ad8b8b9f15647153b191f43005c682d /src/shaders | |
| parent | fef418c8e839ae689aacb14264b0e9e3c3d1071d (diff) | |
refactor: mv get_border_col() to color_c64.wgsl as get_border_c64()
Diffstat (limited to 'src/shaders')
| -rw-r--r-- | src/shaders/math/color_c64.wgsl | 15 |
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.); +} |
