summaryrefslogtreecommitdiff
path: root/cnn_v1/src/cnn_v1_effect.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-15 18:55:42 +0100
committerskal <pascal.massimino@gmail.com>2026-02-15 18:55:42 +0100
commit2f8810f303d06fe78dbec343553c3c97f93f9323 (patch)
tree08303fd16e44823dc2714a39a318e4b5e97ddc5c /cnn_v1/src/cnn_v1_effect.h
parentd4b67e2f6ab48ab9ec658140be4f1999f604559a (diff)
refactor(cnn): rename cnn_effect to cnn_v1_effect for clarity
Renamed files and classes: - cnn_effect.{h,cc} → cnn_v1_effect.{h,cc} - CNNEffect → CNNv1Effect - CNNEffectParams → CNNv1EffectParams - CNNLayerParams → CNNv1LayerParams - CNN_EFFECT.md → CNN_V1_EFFECT.md Updated all references: - C++ includes and class usage - CMake source list - Timeline (workspaces/main/timeline.seq) - Test file (test_demo_effects.cc) - Documentation (CLAUDE.md, PROJECT_CONTEXT.md, READMEs) Tests: 34/34 passing (100%)
Diffstat (limited to 'cnn_v1/src/cnn_v1_effect.h')
-rw-r--r--cnn_v1/src/cnn_v1_effect.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/cnn_v1/src/cnn_v1_effect.h b/cnn_v1/src/cnn_v1_effect.h
new file mode 100644
index 0000000..e820275
--- /dev/null
+++ b/cnn_v1/src/cnn_v1_effect.h
@@ -0,0 +1,53 @@
+// CNN post-processing effect header
+// Multi-layer neural network stylization
+
+#pragma once
+#include "gpu/effect.h"
+#include "gpu/uniform_helper.h"
+
+struct CNNv1LayerParams {
+ int layer_index;
+ float blend_amount; // Blend: mix(input, output, blend_amount)
+ float _pad[2];
+};
+static_assert(sizeof(CNNv1LayerParams) == 16);
+
+struct CNNv1EffectParams {
+ int layer_index = 0; // Which layer to render (0-based)
+ int total_layers = 1; // Total number of layers in the CNN
+ float blend_amount = 1.0f; // Final blend with original input
+};
+
+class CNNv1Effect : public PostProcessEffect {
+ public:
+ explicit CNNv1Effect(const GpuContext& ctx);
+ explicit CNNv1Effect(const GpuContext& ctx, const CNNv1EffectParams& params);
+
+ void init(MainSequence* demo) override;
+ void resize(int width, int height) override;
+ void render(WGPURenderPassEncoder pass,
+ const CommonPostProcessUniforms& uniforms) override;
+ void update_bind_group(WGPUTextureView input_view) override;
+
+ // Layer 0 needs framebuffer capture for original input
+ bool needs_framebuffer_capture() const override {
+ return layer_index_ == 0;
+ }
+
+ void set_beat_modulation(bool enabled, float scale = 1.0f) {
+ beat_modulated_ = enabled;
+ beat_scale_ = scale;
+ }
+
+ private:
+ int layer_index_;
+ int total_layers_;
+ float blend_amount_;
+ bool beat_modulated_ = false;
+ float beat_scale_ = 1.0f;
+ WGPUTextureView input_view_;
+ WGPUTextureView original_view_;
+ UniformBuffer<CNNv1LayerParams> params_buffer_;
+ WGPUBindGroup bind_group_;
+ MainSequence* demo_ = nullptr;
+};