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 +++++++++----- src/main.cc | 10 ++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src') 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 = {}; diff --git a/src/main.cc b/src/main.cc index f612868..d564de0 100644 --- a/src/main.cc +++ b/src/main.cc @@ -133,8 +133,14 @@ int main(int argc, char **argv) { glfwGetFramebufferSize(platform_get_window(), &width, &height); float aspect_ratio = (float)width / (float)height; - float visual_peak = fminf(synth_get_output_peak() * 80.0f, 1.0f); - gpu_draw(visual_peak, aspect_ratio); + // Stronger amplification for visuals + float raw_peak = synth_get_output_peak(); + float visual_peak = raw_peak * 150.0f; + + // Add a non-linear boost for loud peaks to make flashes pop + if (visual_peak > 0.5f) visual_peak += (visual_peak - 0.5f) * 0.5f; + + gpu_draw(fminf(visual_peak, 1.0f), aspect_ratio); audio_update(); } -- cgit v1.2.3