summaryrefslogtreecommitdiff
path: root/src/gpu
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-01-31 00:57:47 +0100
committerskal <pascal.massimino@gmail.com>2026-01-31 00:57:49 +0100
commit2520ae66ce2da210eaeaeba44c467c97e0c3fdd0 (patch)
treecf04b194f81966a109a846e2728cab0875db20d1 /src/gpu
parent91f557d8777d6185ed47927318973d515f8dcbee (diff)
Chore: Remove trailing whitespaces across the codebase
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/gpu.cc32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/gpu/gpu.cc b/src/gpu/gpu.cc
index ec9922a..27c0772 100644
--- a/src/gpu/gpu.cc
+++ b/src/gpu/gpu.cc
@@ -286,7 +286,7 @@ struct Uniforms {
fn vs_main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4<f32> {
let PI = 3.14159265;
let num_sides = 7.0;
-
+
// Pulse scale based on audio peak
let base_scale = 0.5;
let pulse_scale = 0.3 * uniforms.audio_peak;
@@ -298,14 +298,14 @@ fn vs_main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4<
if (sub_idx == 0u) {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
}
-
+
// Apply rotation based on time
let rotation = uniforms.time * 0.5;
let i = tri_idx + f32(sub_idx - 1u);
let angle = i * 2.0 * PI / num_sides + rotation;
let x = scale * cos(angle) / uniforms.aspect_ratio;
let y = scale * sin(angle);
-
+
return vec4<f32>(x, y, 0.0, 1.0);
}
@@ -316,7 +316,7 @@ fn fs_main() -> @location(0) vec4<f32> {
let r = sin(h + 0.0) * 0.5 + 0.5;
let g = sin(h + 2.0) * 0.9 + 0.3;
let b = sin(h + 4.0) * 0.5 + 0.5;
-
+
let boost = uniforms.audio_peak * 0.5;
return vec4<f32>(r + boost, g + boost, b + boost, 0.5); // Alpha 0.5 for blending
}
@@ -347,26 +347,26 @@ fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
}
var p = particles[index];
-
+
// Update Position
p.pos.x = p.pos.x + p.vel.x * 0.016;
p.pos.y = p.pos.y + p.vel.y * 0.016;
p.pos.z = p.pos.z + p.vel.z * 0.016;
-
+
// Gravity / Audio attraction
p.vel.y = p.vel.y - 0.01 * (1.0 + uniforms.audio_peak * 5.0);
-
+
// Rotate
p.rot.x = p.rot.x + p.rot.y * 0.016;
-
+
// Reset if out of bounds
if (p.pos.y < -1.5) {
p.pos.y = 1.5;
- p.pos.x = (f32(index % 100u) / 50.0) - 1.0 + (uniforms.audio_peak * 0.5);
+ p.pos.x = (f32(index % 100u) / 50.0) - 1.0 + (uniforms.audio_peak * 0.5);
p.vel.y = 0.0;
p.vel.x = (f32(index % 10u) - 5.0) * 0.1;
}
-
+
particles[index] = p;
}
)";
@@ -396,10 +396,10 @@ struct VertexOutput {
@vertex
fn vs_main(@builtin(vertex_index) vertex_index : u32, @builtin(instance_index) instance_index : u32) -> VertexOutput {
let p = particles[instance_index];
-
+
// Simple quad expansion
let size = 0.02 + p.pos.z * 0.01 + uniforms.audio_peak * 0.02;
-
+
// Vertex ID 0..5 for 2 triangles (Quad)
// 0 1 2, 2 1 3 (Strip-like order manually mapped)
var offsets = array<vec2<f32>, 6>(
@@ -410,18 +410,18 @@ fn vs_main(@builtin(vertex_index) vertex_index : u32, @builtin(instance_index) i
vec2<f32>( 1.0, -1.0),
vec2<f32>( 1.0, 1.0)
);
-
+
let offset = offsets[vertex_index];
-
+
// Rotate
let c = cos(p.rot.x);
let s = sin(p.rot.x);
let rot_x = offset.x * c - offset.y * s;
let rot_y = offset.x * s + offset.y * c;
-
+
let x = p.pos.x + rot_x * size / uniforms.aspect_ratio;
let y = p.pos.y + rot_y * size;
-
+
var output : VertexOutput;
output.Position = vec4<f32>(x, y, 0.0, 1.0);
output.Color = p.color * (0.5 + 0.5 * uniforms.audio_peak);