diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/gpu/shader.wgsl | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/src/gpu/shader.wgsl b/src/gpu/shader.wgsl index 4e0ec11..371e27f 100644 --- a/src/gpu/shader.wgsl +++ b/src/gpu/shader.wgsl @@ -1,14 +1,39 @@ +struct Uniforms { + audio_peak : f32, +}; + +@group(0) @binding(0) var<uniform> uniforms : Uniforms; + @vertex -fn vs_main(@builtin(vertex_index) i: u32) -> @builtin(position) vec4<f32> { - var pos = array<vec2<f32>, 3>( - vec2<f32>(-1.0, -1.0), - vec2<f32>( 3.0, -1.0), - vec2<f32>(-1.0, 3.0) - ); - return vec4<f32>(pos[i], 0.0, 1.0); +fn vs_main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4<f32> { + let num_sides = 7.0; + let angle = f32(vertex_index) * 2.0 * PI / num_sides; + + // Base size and pulsating scale based on audio peak + let base_scale = 0.5; + let pulse_scale = 0.2 * uniforms.audio_peak; + let scale = base_scale + pulse_scale; + + let x = scale * cos(angle); + let y = scale * sin(angle); + + // Vertices for a heptagon (fan from center) + if (vertex_index == 0) { return vec4<f32>(0.0, 0.0, 0.0, 1.0); } // Center + else if (vertex_index == 1) { return vec4<f32>(x, y, 0.0, 1.0); } // First point + else { // Subsequent points connect to the center and previous point + let prev_angle = f32(vertex_index - 1) * 2.0 * PI / num_sides; + let prev_x = scale * cos(prev_angle); + let prev_y = scale * sin(prev_angle); + return vec4<f32>(prev_x, prev_y, 0.0, 1.0); + } } @fragment fn fs_main() -> @location(0) vec4<f32> { - return vec4<f32>(0.0, 0.0, 0.0, 1.0); -} + // Simple color, maybe with a hue shift based on audio peak + let hue = uniforms.audio_peak * 0.5; // Adjust as needed for desired color range + 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; + return vec4<f32>(r, g, b, 1.0); +}
\ No newline at end of file |
