From 8296fe5180b979b9d1f32f6375b41f0e0a8a399d Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 8 Feb 2026 17:39:33 +0100 Subject: feat(gpu): Add parameter-driven ChromaAberrationEffect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements Task #73 - Extends shader parametrization system to ChromaAberrationEffect following the FlashEffect pattern. Changes: - Added ChromaAberrationParams struct (offset_scale, angle) - Added ChromaUniforms with proper WGSL alignment (32 bytes) - Updated shader to compute offset direction from angle parameter - Extended seq_compiler to parse offset/angle parameters - Updated demo.seq with 2 parameterized instances: * Line 50: offset=0.03 angle=0.785 (45° diagonal, stronger) * Line 76: offset=0.01 angle=1.57 (90° vertical, subtle) Technical details: - Backward-compatible default constructor maintained - Migrated from raw buffer to UniformBuffer - Shader computes direction: vec2(cos(angle), sin(angle)) - Generated code creates ChromaAberrationParams initialization Testing: - All 32/32 tests pass - Demo runs without errors - Binary size: 5.6M stripped (~200-300 bytes impact) Co-Authored-By: Claude Sonnet 4.5 --- src/gpu/effects/flash_effect.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/gpu/effects/flash_effect.h') diff --git a/src/gpu/effects/flash_effect.h b/src/gpu/effects/flash_effect.h index 373b48b..71815d5 100644 --- a/src/gpu/effects/flash_effect.h +++ b/src/gpu/effects/flash_effect.h @@ -9,22 +9,23 @@ // Parameters for FlashEffect (set at construction time) struct FlashEffectParams { - float color[3] = {1.0f, 1.0f, 1.0f}; // Default: white - float decay_rate = 0.98f; // Default: fast decay - float trigger_threshold = 0.7f; // Default: trigger on strong beats + float color[3] = {1.0f, 1.0f, 1.0f}; // Default: white + float decay_rate = 0.98f; // Default: fast decay + float trigger_threshold = 0.7f; // Default: trigger on strong beats }; // Uniform data sent to GPU shader // IMPORTANT: Must match WGSL struct layout with proper alignment // vec3 in WGSL has 16-byte alignment, not 12-byte! struct FlashUniforms { - float flash_intensity; // offset 0 - float intensity; // offset 4 - float _pad1[2]; // offset 8-15 (padding for vec3 alignment) - float color[3]; // offset 16-27 (vec3 aligned to 16 bytes) - float _pad2; // offset 28-31 + float flash_intensity; // offset 0 + float intensity; // offset 4 + float _pad1[2]; // offset 8-15 (padding for vec3 alignment) + float color[3]; // offset 16-27 (vec3 aligned to 16 bytes) + float _pad2; // offset 28-31 }; -static_assert(sizeof(FlashUniforms) == 32, "FlashUniforms must be 32 bytes for WGSL alignment"); +static_assert(sizeof(FlashUniforms) == 32, + "FlashUniforms must be 32 bytes for WGSL alignment"); class FlashEffect : public PostProcessEffect { public: -- cgit v1.2.3