summaryrefslogtreecommitdiff
path: root/workspaces/test/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'workspaces/test/shaders')
-rw-r--r--workspaces/test/shaders/common_uniforms.wgsl14
-rw-r--r--workspaces/test/shaders/ellipse.wgsl2
-rw-r--r--workspaces/test/shaders/particle_spray_compute.wgsl2
3 files changed, 9 insertions, 9 deletions
diff --git a/workspaces/test/shaders/common_uniforms.wgsl b/workspaces/test/shaders/common_uniforms.wgsl
index ce1be53..1ab8939 100644
--- a/workspaces/test/shaders/common_uniforms.wgsl
+++ b/workspaces/test/shaders/common_uniforms.wgsl
@@ -1,11 +1,11 @@
struct CommonUniforms {
- resolution: vec2<f32>,
- _pad0: f32,
- _pad1: f32,
- aspect_ratio: f32,
- time: f32,
- beat: f32,
- audio_intensity: f32,
+ resolution: vec2<f32>, // Screen dimensions
+ aspect_ratio: f32, // Width/height ratio
+ time: f32, // Physical time in seconds (unaffected by tempo)
+ beat_time: f32, // Musical time in beats (absolute, tempo-scaled)
+ beat_phase: f32, // Fractional beat (0.0-1.0 within current beat)
+ audio_intensity: f32, // Audio peak for beat sync
+ _pad: f32, // Padding
};
struct GlobalUniforms {
view_proj: mat4x4<f32>,
diff --git a/workspaces/test/shaders/ellipse.wgsl b/workspaces/test/shaders/ellipse.wgsl
index 05dfcfc..69b2712 100644
--- a/workspaces/test/shaders/ellipse.wgsl
+++ b/workspaces/test/shaders/ellipse.wgsl
@@ -46,6 +46,6 @@ fn sdEllipse(p: vec2<f32>, ab: vec2<f32>) -> f32 {
@fragment fn fs_main(@builtin(position) p: vec4<f32>) -> @location(0) vec4<f32> {
let uv = (p.xy / uniforms.resolution - 0.5) * 2.0;
let movement = vec2<f32>(sin(uniforms.time * 0.7), cos(uniforms.time * 0.5));
- let d = sdEllipse((uv * vec2<f32>(uniforms.aspect_ratio, 1.0)) - movement, vec2<f32>(0.5, 0.3) * (1.0 + uniforms.beat * 0.2));
+ let d = sdEllipse((uv * vec2<f32>(uniforms.aspect_ratio, 1.0)) - movement, vec2<f32>(0.5, 0.3) * (1.0 + uniforms.beat_phase * 0.2));
return mix(vec4<f32>(0.2, 0.8, 0.4, 1.0), vec4<f32>(0.0), smoothstep(0.0, 0.01, d));
}
diff --git a/workspaces/test/shaders/particle_spray_compute.wgsl b/workspaces/test/shaders/particle_spray_compute.wgsl
index a4041f2..4b6e48f 100644
--- a/workspaces/test/shaders/particle_spray_compute.wgsl
+++ b/workspaces/test/shaders/particle_spray_compute.wgsl
@@ -29,7 +29,7 @@ fn main(@builtin(global_invocation_id) id: vec3<u32>) {
p.color = vec4<f32>(hash(r + 0.1), hash(r + 0.2), 1.0, 1.0);
}
let new_pos = p.pos.xyz + p.vel.xyz * 0.016;
- p.pos = vec4<f32>(new_pos, p.pos.w - 0.01 * (1.0 + uniforms.beat));
+ p.pos = vec4<f32>(new_pos, p.pos.w - 0.01 * (1.0 + uniforms.beat_phase));
p.vel.y = p.vel.y - 0.01;
particles[i] = p;
}