From f12b5ebc74825817df54677e261b92200bfac84a Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 28 Jan 2026 10:26:12 +0100 Subject: feat(visuals): Enhance colors and add background flashes Improves the audio-visual synchronization by increasing peak amplification and adding dynamic background flashes. - src/gpu/gpu.cc: Updated fragment shader with more vibrant hue calculation and implemented reactive clear color for flashes. - src/main.cc: Increased peak multiplier to 150x and added non-linear boost for strong peaks. --- src/gpu/gpu.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/gpu') diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc index 43aef7c..1f2c7f8 100644 --- a/src/gpu/gpu.cc +++ b/src/gpu/gpu.cc @@ -129,10 +129,11 @@ fn vs_main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4< @fragment fn fs_main() -> @location(0) vec4 { - let hue = uniforms.audio_peak * 0.5; - let r = sin(hue + 0.0) * 0.5 + 0.5; - let g = sin(hue + 2.0) * 0.5 + 0.5; - let b = sin(hue + 4.0) * 0.5 + 0.5; + // More vibrant hue: shift through colors based on peak + let h = uniforms.audio_peak * 2.0; + let r = sin(h + 0.0) * 0.5 + 0.5; + let g = sin(h + 2.0) * 0.5 + 0.5; + let b = sin(h + 4.0) * 0.5 + 0.5; return vec4(r, g, b, 1.0); } )"; @@ -289,7 +290,10 @@ void gpu_draw(float audio_peak, float aspect_ratio) { color_attachment.resolveTarget = nullptr; color_attachment.loadOp = WGPULoadOp_Clear; color_attachment.storeOp = WGPUStoreOp_Store; - color_attachment.clearValue = {0.1, 0.2, 0.3, 1.0}; + + // Background flash based on peak + float flash = uniforms.audio_peak * 0.4f; + color_attachment.clearValue = {0.05 + flash, 0.1 + flash, 0.2 + flash, 1.0}; color_attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED; WGPURenderPassDescriptor render_pass_desc = {}; -- cgit v1.2.3