diff options
Diffstat (limited to 'workspaces/main/shaders')
| -rw-r--r-- | workspaces/main/shaders/particle_compute.wgsl | 5 | ||||
| -rw-r--r-- | workspaces/main/shaders/particle_compute_v2.wgsl | 31 | ||||
| -rw-r--r-- | workspaces/main/shaders/particle_render.wgsl | 5 | ||||
| -rw-r--r-- | workspaces/main/shaders/particle_render_v2.wgsl | 53 | ||||
| -rw-r--r-- | workspaces/main/shaders/rotating_cube.wgsl (renamed from workspaces/main/shaders/rotating_cube_v2.wgsl) | 0 |
5 files changed, 6 insertions, 88 deletions
diff --git a/workspaces/main/shaders/particle_compute.wgsl b/workspaces/main/shaders/particle_compute.wgsl index ae513c8..d7a24b6 100644 --- a/workspaces/main/shaders/particle_compute.wgsl +++ b/workspaces/main/shaders/particle_compute.wgsl @@ -1,3 +1,4 @@ +// Particle simulation (compute shader) - V2 struct Particle { pos: vec4<f32>, vel: vec4<f32>, @@ -5,10 +6,10 @@ struct Particle { color: vec4<f32>, }; -#include "common_uniforms" +#include "sequence_uniforms" @group(0) @binding(0) var<storage, read_write> particles: array<Particle>; -@group(0) @binding(1) var<uniform> uniforms: CommonUniforms; +@group(0) @binding(1) var<uniform> uniforms: UniformsSequenceParams; @compute @workgroup_size(64) fn main(@builtin(global_invocation_id) id: vec3<u32>) { diff --git a/workspaces/main/shaders/particle_compute_v2.wgsl b/workspaces/main/shaders/particle_compute_v2.wgsl deleted file mode 100644 index 3683826..0000000 --- a/workspaces/main/shaders/particle_compute_v2.wgsl +++ /dev/null @@ -1,31 +0,0 @@ -// Particle simulation (compute shader) - V2 -struct Particle { - pos: vec4<f32>, - vel: vec4<f32>, - rot: vec4<f32>, - color: vec4<f32>, -}; - -#include "sequence_v2_uniforms" - -@group(0) @binding(0) var<storage, read_write> particles: array<Particle>; -@group(0) @binding(1) var<uniform> uniforms: UniformsSequenceParams; - -@compute @workgroup_size(64) -fn main(@builtin(global_invocation_id) id: vec3<u32>) { - let i = id.x; - if (i >= arrayLength(&particles)) { - return; - } - var p = particles[i]; - let new_pos = p.pos.xyz + p.vel.xyz * 0.016; - p.pos = vec4<f32>(new_pos, p.pos.w); - p.vel.y = p.vel.y - 0.01 * (1.0 + uniforms.audio_intensity * 5.0); - p.rot.x = p.rot.x + p.rot.y * 0.016; - if (p.pos.y < -1.5) { - p.pos.y = 1.5; - p.pos.x = (f32(i % 100u) / 50.0) - 1.0 + (uniforms.audio_intensity * 0.5); - p.vel.y = 0.0; - } - particles[i] = p; -} diff --git a/workspaces/main/shaders/particle_render.wgsl b/workspaces/main/shaders/particle_render.wgsl index 6a2b636..dd83220 100644 --- a/workspaces/main/shaders/particle_render.wgsl +++ b/workspaces/main/shaders/particle_render.wgsl @@ -1,3 +1,4 @@ +// Particle rendering (vertex + fragment) - V2 struct Particle { pos: vec4<f32>, vel: vec4<f32>, @@ -5,10 +6,10 @@ struct Particle { color: vec4<f32>, }; -#include "common_uniforms" +#include "sequence_uniforms" @group(0) @binding(0) var<storage, read> particles: array<Particle>; -@group(0) @binding(1) var<uniform> uniforms: CommonUniforms; +@group(0) @binding(1) var<uniform> uniforms: UniformsSequenceParams; struct VSOut { @builtin(position) pos: vec4<f32>, diff --git a/workspaces/main/shaders/particle_render_v2.wgsl b/workspaces/main/shaders/particle_render_v2.wgsl deleted file mode 100644 index 8663658..0000000 --- a/workspaces/main/shaders/particle_render_v2.wgsl +++ /dev/null @@ -1,53 +0,0 @@ -// Particle rendering (vertex + fragment) - V2 -struct Particle { - pos: vec4<f32>, - vel: vec4<f32>, - rot: vec4<f32>, - color: vec4<f32>, -}; - -#include "sequence_v2_uniforms" - -@group(0) @binding(0) var<storage, read> particles: array<Particle>; -@group(0) @binding(1) var<uniform> uniforms: UniformsSequenceParams; - -struct VSOut { - @builtin(position) pos: vec4<f32>, - @location(0) color: vec4<f32>, - @location(1) uv: vec2<f32>, -}; - -@vertex fn vs_main(@builtin(vertex_index) vi: u32, @builtin(instance_index) ii: u32) -> VSOut { - let p = particles[ii]; - let size = 0.02 + p.pos.z * 0.01 + uniforms.audio_intensity * 0.02; - var offsets = array<vec2<f32>, 6>( - vec2<f32>(-1, -1), - vec2<f32>(1, -1), - vec2<f32>(-1, 1), - vec2<f32>(-1, 1), - vec2<f32>(1, -1), - vec2<f32>(1, 1) - ); - let offset = offsets[vi]; - let c = cos(p.rot.x); - let s = sin(p.rot.x); - let rotated_offset = vec2<f32>(offset.x * c - offset.y * s, offset.x * s + offset.y * c); - let pos = vec2<f32>(p.pos.x + rotated_offset.x * size / uniforms.aspect_ratio, p.pos.y + rotated_offset.y * size); - - // Fade based on lifetime (p.pos.w goes from 1.0 to 0.0) - let lifetime_fade = p.pos.w; - let color_with_fade = vec4<f32>(p.color.rgb * (0.5 + 0.5 * uniforms.audio_intensity), p.color.a * lifetime_fade); - - return VSOut(vec4<f32>(pos, 0.0, 1.0), color_with_fade, offset); -} - -@fragment fn fs_main(@location(0) color: vec4<f32>, @location(1) uv: vec2<f32>) -> @location(0) vec4<f32> { - // Calculate distance from center for circular shape - let dist = length(uv); - - // Smooth circular falloff (1.0 at center, 0.0 at edge) - let circle_alpha = smoothstep(1.0, 0.5, dist); - - // Apply circular fade to alpha channel - return vec4<f32>(color.rgb, color.a * circle_alpha); -} diff --git a/workspaces/main/shaders/rotating_cube_v2.wgsl b/workspaces/main/shaders/rotating_cube.wgsl index d7e4cae..d7e4cae 100644 --- a/workspaces/main/shaders/rotating_cube_v2.wgsl +++ b/workspaces/main/shaders/rotating_cube.wgsl |
