summaryrefslogtreecommitdiff
path: root/src/effects
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 /src/effects
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>
Diffstat (limited to 'src/effects')
-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
4 files changed, 68 insertions, 0 deletions
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;