summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-20 12:08:34 +0100
committerskal <pascal.massimino@gmail.com>2026-02-20 12:08:34 +0100
commit850388bcaabf057beed8f126002b7b663183b2d8 (patch)
treef55fad742d99dc91d2bf32ad54a27f95e8a183f3
parent1030807a58c8f4315d209c3756a9f98d8dc6bd91 (diff)
feat(sequence): port Scene1Effect + fix seq_compiler absolute time bug
- Add Scene1 effect: raymarching cube+sphere+ground (reflections, shadows) - Fix scene1.wgsl: binding 0→2, CommonUniforms→UniformsSequenceParams - Replace Heptagon+Placeholder stub in heptagon_scene with Scene1 - Fix seq_compiler.py: emit seq.start_time+effect.start/end (absolute times) so dispatch_render active check works correctly for all sequences Bug: effects in sequences starting after t=0 were never active because local times (e.g. 0-8) never satisfied params.time<end for absolute time 20+. 34/34 tests passing. handoff(Gemini): seq_compiler now emits absolute effect times. All existing sequences affected — verify visual output across the full timeline. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rw-r--r--PROJECT_CONTEXT.md4
-rw-r--r--cmake/DemoSourceLists.cmake1
-rw-r--r--doc/COMPLETED.md13
-rw-r--r--src/effects/scene1_effect.cc45
-rw-r--r--src/effects/scene1_effect.h21
-rw-r--r--src/effects/shaders.cc1
-rw-r--r--src/effects/shaders.h1
-rw-r--r--src/gpu/demo_effects.h1
-rw-r--r--src/tests/gpu/test_demo_effects.cc3
-rwxr-xr-xtools/seq_compiler.py2
-rw-r--r--workspaces/main/shaders/scene1.wgsl4
-rw-r--r--workspaces/main/timeline.seq4
12 files changed, 92 insertions, 8 deletions
diff --git a/PROJECT_CONTEXT.md b/PROJECT_CONTEXT.md
index dee9c77..758b83e 100644
--- a/PROJECT_CONTEXT.md
+++ b/PROJECT_CONTEXT.md
@@ -39,8 +39,8 @@
- **Effects:** CNN post-processing: CNNEffect (v1) and CNNv2Effect operational. CNN v2: sigmoid activation, storage buffer weights (~3.2 KB), 7D static features, dynamic layers. Training stable, convergence validated.
- **Tools:** CNN test tool operational. Texture readback utility functional. Timeline editor (web-based, beat-aligned, audio playback).
- **Build:** Asset dependency tracking. Size measurement. Hot-reload (debug-only).
-- **Sequence:** DAG-based effect routing with explicit node system. Python compiler with topological sort and ping-pong optimization. 9 effects operational (Passthrough, Placeholder, GaussianBlur, Heptagon, Particles, RotatingCube, Hybrid3D, Flash, PeakMeter). See `doc/SEQUENCE.md`.
-- **Testing:** **35/35 passing**
+- **Sequence:** DAG-based effect routing with explicit node system. Python compiler with topological sort and ping-pong optimization. 10 effects operational (Passthrough, Placeholder, GaussianBlur, Heptagon, Particles, RotatingCube, Hybrid3D, Flash, PeakMeter, Scene1). Effect times are absolute (seq_compiler adds sequence start offset). See `doc/SEQUENCE.md`.
+- **Testing:** **34/34 passing**
---
diff --git a/cmake/DemoSourceLists.cmake b/cmake/DemoSourceLists.cmake
index b7bc843..bc943b6 100644
--- a/cmake/DemoSourceLists.cmake
+++ b/cmake/DemoSourceLists.cmake
@@ -39,6 +39,7 @@ set(COMMON_GPU_EFFECTS
src/effects/hybrid3_d_effect.cc
src/effects/flash_effect.cc
src/effects/peak_meter_effect.cc
+ src/effects/scene1_effect.cc
# TODO: Port CNN effects to v2 (complex v1 dependencies)
# cnn_v1/src/cnn_v1_effect.cc
# cnn_v2/src/cnn_v2_effect.cc
diff --git a/doc/COMPLETED.md b/doc/COMPLETED.md
index 1fb51f5..72e389d 100644
--- a/doc/COMPLETED.md
+++ b/doc/COMPLETED.md
@@ -29,6 +29,19 @@ Detailed historical documents have been moved to `doc/archive/` for reference:
Use `read @doc/archive/FILENAME.md` to access archived documents.
+## Recently Completed (February 20, 2026)
+
+- [x] **Port Scene1Effect + Fix seq_compiler Timing Bug**
+ - **Goal**: Port `scene1.wgsl` (raymarching cube + sphere + ground, reflections, shadows) as `Scene1` effect replacing `Placeholder` stub in `heptagon_scene` sequence.
+ - **Implementation**:
+ - `src/effects/scene1_effect.h/.cc`: New effect mirroring Heptagon pattern (dummy texture, `create_post_process_pipeline`).
+ - `workspaces/main/shaders/scene1.wgsl`: Fixed binding (`@binding(0)` → `@binding(2)`) and struct (`CommonUniforms` → `UniformsSequenceParams`) to match post-process pipeline layout.
+ - Added to `COMMON_GPU_EFFECTS`, `demo_effects.h`, and `test_demo_effects.cc`. 10/10 effects tested.
+ - `workspaces/main/timeline.seq`: Replaced Heptagon+Placeholder chain with single `Scene1 source -> sink 0.00 8.00`.
+ - **Bug Fixed**: `seq_compiler.py` emitted local effect times (e.g. `0.0f, 8.0f`) but `dispatch_render` checks against absolute `params.time`. Effects in sequences starting after t=0 were **never active** (e.g. Scene1 at t=20+ never satisfied `time < 8`). Fixed by emitting `seq.start_time + effect.start/end` as absolute times. All sequences now render correctly.
+ - **Files**: `src/effects/scene1_effect.{h,cc}` (new), `src/effects/shaders.{h,cc}`, `cmake/DemoSourceLists.cmake`, `src/gpu/demo_effects.h`, `src/tests/gpu/test_demo_effects.cc`, `workspaces/main/shaders/scene1.wgsl`, `workspaces/main/timeline.seq`, `src/generated/timeline.cc`, `tools/seq_compiler.py`
+ - **Tests**: 34/34 passing
+
## Recently Completed (February 18, 2026)
- [x] **MQ Spectral Editor Improvements**
diff --git a/src/effects/scene1_effect.cc b/src/effects/scene1_effect.cc
new file mode 100644
index 0000000..7c109e7
--- /dev/null
+++ b/src/effects/scene1_effect.cc
@@ -0,0 +1,45 @@
+// Scene1 effect implementation
+
+#include "effects/scene1_effect.h"
+#include "effects/shaders.h"
+#include "gpu/gpu.h"
+#include "gpu/post_process_helper.h"
+#include "util/fatal_error.h"
+
+Scene1::Scene1(const GpuContext& ctx, const std::vector<std::string>& inputs,
+ const std::vector<std::string>& outputs, float start_time,
+ float end_time)
+ : Effect(ctx, inputs, outputs, start_time, end_time) {
+ HEADLESS_RETURN_IF_NULL(ctx_.device);
+
+ create_nearest_sampler();
+ create_dummy_scene_texture();
+
+ pipeline_.set(create_post_process_pipeline(
+ ctx_.device, WGPUTextureFormat_RGBA8Unorm, scene1_shader_wgsl));
+}
+
+void Scene1::render(WGPUCommandEncoder encoder,
+ const UniformsSequenceParams& params,
+ NodeRegistry& nodes) {
+ WGPUTextureView output_view = nodes.get_view(output_nodes_[0]);
+
+ pp_update_bind_group(ctx_.device, pipeline_.get(), bind_group_.get_address(),
+ dummy_texture_view_.get(), uniforms_buffer_.get(),
+ {nullptr, 0});
+
+ WGPURenderPassColorAttachment color_attachment = {};
+ gpu_init_color_attachment(color_attachment, output_view);
+
+ WGPURenderPassDescriptor pass_desc = {};
+ pass_desc.colorAttachmentCount = 1;
+ pass_desc.colorAttachments = &color_attachment;
+
+ WGPURenderPassEncoder pass =
+ wgpuCommandEncoderBeginRenderPass(encoder, &pass_desc);
+ wgpuRenderPassEncoderSetPipeline(pass, pipeline_.get());
+ wgpuRenderPassEncoderSetBindGroup(pass, 0, bind_group_.get(), 0, nullptr);
+ wgpuRenderPassEncoderDraw(pass, 3, 1, 0, 0); // Fullscreen triangle
+ wgpuRenderPassEncoderEnd(pass);
+ wgpuRenderPassEncoderRelease(pass);
+}
diff --git a/src/effects/scene1_effect.h b/src/effects/scene1_effect.h
new file mode 100644
index 0000000..781cbae
--- /dev/null
+++ b/src/effects/scene1_effect.h
@@ -0,0 +1,21 @@
+// Scene1 effect - raymarching cube & sphere scene
+
+#pragma once
+
+#include "gpu/effect.h"
+#include "gpu/uniform_helper.h"
+#include "gpu/wgpu_resource.h"
+
+class Scene1 : public Effect {
+ public:
+ Scene1(const GpuContext& ctx, const std::vector<std::string>& inputs,
+ const std::vector<std::string>& outputs, float start_time,
+ float end_time);
+
+ void render(WGPUCommandEncoder encoder, const UniformsSequenceParams& params,
+ NodeRegistry& nodes) override;
+
+ private:
+ RenderPipeline pipeline_;
+ BindGroup bind_group_;
+};
diff --git a/src/effects/shaders.cc b/src/effects/shaders.cc
index d181632..4329427 100644
--- a/src/effects/shaders.cc
+++ b/src/effects/shaders.cc
@@ -92,6 +92,7 @@ const char* particle_render_wgsl =
const char* rotating_cube_wgsl =
SafeGetAsset(AssetId::ASSET_SHADER_ROTATING_CUBE_V2);
const char* flash_shader_wgsl = SafeGetAsset(AssetId::ASSET_SHADER_FLASH);
+const char* scene1_shader_wgsl = SafeGetAsset(AssetId::ASSET_SHADER_SCENE1);
// Compute shaders
const char* gen_noise_compute_wgsl =
diff --git a/src/effects/shaders.h b/src/effects/shaders.h
index b8700f5..ee6c65e 100644
--- a/src/effects/shaders.h
+++ b/src/effects/shaders.h
@@ -14,6 +14,7 @@ extern const char* particle_compute_wgsl;
extern const char* particle_render_wgsl;
extern const char* rotating_cube_wgsl;
extern const char* flash_shader_wgsl;
+extern const char* scene1_shader_wgsl;
// Compute shaders
extern const char* gen_noise_compute_wgsl;
diff --git a/src/gpu/demo_effects.h b/src/gpu/demo_effects.h
index 2825891..f746326 100644
--- a/src/gpu/demo_effects.h
+++ b/src/gpu/demo_effects.h
@@ -26,6 +26,7 @@
#include "effects/peak_meter_effect.h"
#include "effects/placeholder_effect.h"
#include "effects/rotating_cube_effect.h"
+#include "effects/scene1_effect.h"
// TODO: Port CNN effects
// #include "../../cnn_v1/src/cnn_v1_effect.h"
// #include "../../cnn_v2/src/cnn_v2_effect.h"
diff --git a/src/tests/gpu/test_demo_effects.cc b/src/tests/gpu/test_demo_effects.cc
index f193c76..132e489 100644
--- a/src/tests/gpu/test_demo_effects.cc
+++ b/src/tests/gpu/test_demo_effects.cc
@@ -64,6 +64,9 @@ static void test_effects() {
{"PeakMeter", std::make_shared<PeakMeter>(
fixture.ctx(), std::vector<std::string>{"source"},
std::vector<std::string>{"sink"}, 0.0f, 1000.0f)},
+ {"Scene1", std::make_shared<Scene1>(
+ fixture.ctx(), std::vector<std::string>{"source"},
+ std::vector<std::string>{"sink"}, 0.0f, 1000.0f)},
};
int passed = 0;
diff --git a/tools/seq_compiler.py b/tools/seq_compiler.py
index 18d5a1f..2e51574 100755
--- a/tools/seq_compiler.py
+++ b/tools/seq_compiler.py
@@ -437,7 +437,7 @@ class {class_name} : public Sequence {{
.effect = std::make_shared<{effect.class_name}>(ctx,
std::vector<std::string>{{{inputs_str}}},
std::vector<std::string>{{{outputs_str}}},
- {effect.start}f, {effect.end}f),
+ {seq.start_time + effect.start}f, {seq.start_time + effect.end}f),
.input_nodes = {{{inputs_str}}},
.output_nodes = {{{outputs_str}}},
.execution_order = {effect.execution_order}
diff --git a/workspaces/main/shaders/scene1.wgsl b/workspaces/main/shaders/scene1.wgsl
index 8d5d5db..2f1174a 100644
--- a/workspaces/main/shaders/scene1.wgsl
+++ b/workspaces/main/shaders/scene1.wgsl
@@ -1,13 +1,13 @@
// Scene1 effect shader - ShaderToy conversion (raymarching cube & sphere)
// Source: Saturday cubism experiment by skal
-#include "common_uniforms"
+#include "sequence_uniforms"
#include "math/color"
#include "math/utils"
#include "math/sdf_shapes"
#include "render/raymarching"
-@group(0) @binding(0) var<uniform> uniforms: CommonUniforms;
+@group(0) @binding(2) var<uniform> uniforms: UniformsSequenceParams;
const PI: f32 = 3.141592654;
const TAU: f32 = 6.283185307;
diff --git a/workspaces/main/timeline.seq b/workspaces/main/timeline.seq
index 77f013d..2b843a7 100644
--- a/workspaces/main/timeline.seq
+++ b/workspaces/main/timeline.seq
@@ -25,9 +25,7 @@ SEQUENCE 16.00 2 "hybrid_heptagon"
EFFECT + Hybrid3D temp1 -> sink 0.00 4.00
SEQUENCE 20.00 0 "heptagon_scene"
- # Heptagon -> Scene1 (placeholder) -> sink
- EFFECT + Heptagon source -> temp1 0.00 8.00
- EFFECT + Placeholder temp1 -> sink 0.00 8.00
+ EFFECT + Scene1 source -> sink 0.00 8.00
SEQUENCE 28.00 0 "fade_test"
# Heptagon -> Fade (placeholder) -> sink