diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-08 17:43:44 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-08 17:43:44 +0100 |
| commit | 4b23fdc63d422b31b6ad86d34218e7b66b462514 (patch) | |
| tree | 028e4fec0d49a7a3a997bd446c9f1ce480ce787b /assets | |
| parent | 8296fe5180b979b9d1f32f6375b41f0e0a8a399d (diff) | |
feat(gpu): Add parameter-driven GaussianBlurEffect
Extends shader parametrization system to GaussianBlurEffect with
strength parameter (Task #73 continued).
Changes:
- Added GaussianBlurParams struct (strength, default: 2.0f)
- Added GaussianBlurUniforms with proper WGSL alignment (32 bytes)
- Updated shader to use parameterized strength instead of hardcoded 2.0
- Extended seq_compiler to parse strength parameter
- Updated demo.seq with 2 parameterized instances:
* Line 38: strength=3.0 (stronger blur for particles)
* Line 48: strength=1.5 (subtle blur)
Technical details:
- Backward-compatible default constructor maintained
- Migrated from raw buffer to UniformBuffer<GaussianBlurUniforms>
- Shader replaces 'let base_size = 2.0' with 'uniforms.strength'
- Generated code creates GaussianBlurParams initialization
Testing:
- All 32/32 tests pass
- Demo runs without errors
- Generated code verified correct
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'assets')
| -rw-r--r-- | assets/demo.seq | 4 | ||||
| -rw-r--r-- | assets/final/shaders/gaussian_blur.wgsl | 14 |
2 files changed, 10 insertions, 8 deletions
diff --git a/assets/demo.seq b/assets/demo.seq index 8f84c30..cada95e 100644 --- a/assets/demo.seq +++ b/assets/demo.seq @@ -35,7 +35,7 @@ SEQUENCE 4b 0 SEQUENCE 6b 1 EFFECT + ParticleSprayEffect 0 4 # Priority 0 (spray particles) EFFECT + ParticlesEffect 0 4 # Priority 1 - EFFECT = GaussianBlurEffect 0 8 # Priority 1 (same layer) + EFFECT = GaussianBlurEffect 0 8 strength=3.0 # Priority 1 (stronger blur) SEQUENCE 7b 0 EFFECT + HeptagonEffect 0.0 .2 # Priority 0 @@ -46,7 +46,7 @@ SEQUENCE 7b 0 SEQUENCE 8b 3 EFFECT + ThemeModulationEffect 0 4 # Priority 0 EFFECT = HeptagonEffect 0.0 4.0 # Priority 0 (same layer) - EFFECT + GaussianBlurEffect 0 8 # Priority 1 + EFFECT + GaussianBlurEffect 0 8 strength=1.5 # Priority 1 (subtle blur) EFFECT + ChromaAberrationEffect 0 6 offset=0.03 angle=0.785 # Priority 2 (diagonal, stronger) EFFECT + SolarizeEffect 0 10 # Priority 3 diff --git a/assets/final/shaders/gaussian_blur.wgsl b/assets/final/shaders/gaussian_blur.wgsl index 7d39ac4..e848c6b 100644 --- a/assets/final/shaders/gaussian_blur.wgsl +++ b/assets/final/shaders/gaussian_blur.wgsl @@ -6,7 +6,10 @@ struct Uniforms { beat: f32, intensity: f32, aspect_ratio: f32, - resolution: vec2<f32>, + width: f32, + height: f32, + strength: f32, + _pad: f32, }; @group(0) @binding(2) var<uniform> uniforms: Uniforms; @@ -21,17 +24,16 @@ struct Uniforms { } @fragment fn fs_main(@builtin(position) p: vec4<f32>) -> @location(0) vec4<f32> { - let uv = p.xy / uniforms.resolution; + let uv = p.xy / vec2<f32>(uniforms.width, uniforms.height); var res = vec4<f32>(0.0); - // Reduced base size + dramatic beat pulsation - let base_size = 2.0; + // Parameterized strength + dramatic beat pulsation let pulse = 0.5 + uniforms.intensity * 2.0; // Pulsate between 0.5x and 2.5x with beat - let size = base_size * pulse; + let size = uniforms.strength * pulse; for (var x: f32 = -2.0; x <= 2.0; x += 1.0) { for (var y: f32 = -2.0; y <= 2.0; y += 1.0) { - res += textureSample(txt, smplr, uv + vec2<f32>(x, y) * size / uniforms.resolution.x); + res += textureSample(txt, smplr, uv + vec2<f32>(x, y) * size / uniforms.width); } } return res / 25.0; |
