summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-08 17:39:33 +0100
committerskal <pascal.massimino@gmail.com>2026-02-08 17:39:33 +0100
commit8296fe5180b979b9d1f32f6375b41f0e0a8a399d (patch)
tree28918defcd64001105f8f631a3c0494abd580026 /tools
parentb85635ea92ace57e4d94288031a3a61a96fcbd2a (diff)
feat(gpu): Add parameter-driven ChromaAberrationEffect
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<ChromaUniforms> - 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 <noreply@anthropic.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/seq_compiler.cc37
1 files changed, 29 insertions, 8 deletions
diff --git a/tools/seq_compiler.cc b/tools/seq_compiler.cc
index 4a6b554..d89ab3d 100644
--- a/tools/seq_compiler.cc
+++ b/tools/seq_compiler.cc
@@ -38,7 +38,8 @@ std::string trim(const std::string& str) {
}
// Parse key=value parameters from extra_args string
-// Example: "color=1.0,0.0,0.0 decay=0.95" -> {{"color", "1.0,0.0,0.0"}, {"decay", "0.95"}}
+// Example: "color=1.0,0.0,0.0 decay=0.95" -> {{"color", "1.0,0.0,0.0"},
+// {"decay", "0.95"}}
std::vector<std::pair<std::string, std::string>>
parse_parameters(const std::string& args) {
std::vector<std::pair<std::string, std::string>> params;
@@ -167,8 +168,8 @@ void analyze_effect_depth(const std::vector<SequenceEntry>& sequences,
std::cout << "Sample rate: " << sample_rate << " Hz (every " << dt << "s)\n";
std::cout << "\n";
- std::cout << "Max concurrent effects: " << max_depth << " at t=" << max_depth_time
- << "s\n";
+ std::cout << "Max concurrent effects: " << max_depth
+ << " at t=" << max_depth_time << "s\n";
std::cout << "\n";
// Print histogram
@@ -200,7 +201,8 @@ void analyze_effect_depth(const std::vector<SequenceEntry>& sequences,
// Print bottleneck warnings
if (max_depth > 5) {
std::cout << "\n⚠ WARNING: Performance bottlenecks detected!\n";
- std::cout << "Found " << peaks.size() << " time periods with >5 effects:\n\n";
+ std::cout << "Found " << peaks.size()
+ << " time periods with >5 effects:\n\n";
int peak_count = 0;
for (const auto& peak : peaks) {
@@ -850,7 +852,8 @@ int main(int argc, char* argv[]) {
std::string extra_args = "";
if (!rest_of_line.empty()) {
params = parse_parameters(rest_of_line);
- // Keep extra_args for backward compatibility (if no key=value pairs found)
+ // Keep extra_args for backward compatibility (if no key=value pairs
+ // found)
if (params.empty()) {
extra_args = ", " + rest_of_line;
}
@@ -937,9 +940,27 @@ int main(int argc, char* argv[]) {
}
}
- out_file << " seq->add_effect(std::make_shared<" << eff.class_name
- << ">(ctx, p), " << eff.start << "f, " << eff.end << "f, "
- << eff.priority << ");\n";
+ out_file << " seq->add_effect(std::make_shared<"
+ << eff.class_name << ">(ctx, p), " << eff.start << "f, "
+ << eff.end << "f, " << eff.priority << ");\n";
+ out_file << " }\n";
+ } else if (!eff.params.empty() &&
+ eff.class_name == "ChromaAberrationEffect") {
+ // Generate parameter struct initialization for ChromaAberrationEffect
+ out_file << " {\n";
+ out_file << " ChromaAberrationParams p;\n";
+
+ for (const auto& [key, value] : eff.params) {
+ if (key == "offset") {
+ out_file << " p.offset_scale = " << value << "f;\n";
+ } else if (key == "angle") {
+ out_file << " p.angle = " << value << "f;\n";
+ }
+ }
+
+ out_file << " seq->add_effect(std::make_shared<"
+ << eff.class_name << ">(ctx, p), " << eff.start << "f, "
+ << eff.end << "f, " << eff.priority << ");\n";
out_file << " }\n";
} else {
// No parameters or unsupported effect - use default constructor