summaryrefslogtreecommitdiff
path: root/src/gpu/effects/scene1_effect.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-10 18:19:30 +0100
committerskal <pascal.massimino@gmail.com>2026-02-10 18:19:30 +0100
commit225ff0313c5021c3f1ec2bf5dd61114032b925a7 (patch)
tree33fce14571651158a409d9acf8494cff69dfe8dc /src/gpu/effects/scene1_effect.cc
parent532220d2abb2b48307f049c4ad5f545d4c8934d6 (diff)
feat: Add Scene1 effect from ShaderToy (raymarching cube & sphere)
Converted ShaderToy shader (Saturday cubism experiment) to Scene1Effect following EFFECT_WORKFLOW.md automation guidelines. **Changes:** - Created Scene1Effect (.h, .cc) as scene effect (not post-process) - Converted GLSL to WGSL with manual fixes: - Replaced RESOLUTION/iTime with uniforms.resolution/time - Fixed const expressions (normalize not allowed in const) - Converted mainImage() to fs_main() return value - Manual matrix rotation for scene transformation - Added shader asset to workspaces/main/assets.txt - Registered in CMakeLists.txt (both GPU_SOURCES sections) - Added to demo_effects.h and shaders declarations - Added to timeline.seq at 22.5s for 10s duration - Added to test_demo_effects.cc scene_effects list **Shader features:** - Raymarching cube and sphere with ground plane - Reflections and soft shadows - Sky rendering with sun and horizon glow - ACES tonemapping and sRGB output - Time-based rotation animation **Tests:** All effects tests passing (5/9 scene, 9/9 post-process) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/gpu/effects/scene1_effect.cc')
-rw-r--r--src/gpu/effects/scene1_effect.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/gpu/effects/scene1_effect.cc b/src/gpu/effects/scene1_effect.cc
new file mode 100644
index 0000000..a6733b7
--- /dev/null
+++ b/src/gpu/effects/scene1_effect.cc
@@ -0,0 +1,28 @@
+// This file is part of the 64k demo project.
+// Scene1 effect - ShaderToy conversion (raymarching scene)
+
+#include "gpu/demo_effects.h"
+#include "gpu/gpu.h"
+
+Scene1Effect::Scene1Effect(const GpuContext& ctx) : Effect(ctx) {
+ ResourceBinding bindings[] = {{uniforms_.get(), WGPUBufferBindingType_Uniform}};
+ pass_ = gpu_create_render_pass(ctx_.device, ctx_.format, scene1_shader_wgsl,
+ bindings, 1);
+ pass_.vertex_count = 3;
+}
+
+void Scene1Effect::render(WGPURenderPassEncoder pass, float t, float b,
+ float i, float a) {
+ CommonPostProcessUniforms u = {
+ .resolution = {(float)width_, (float)height_},
+ ._pad = {0.0f, 0.0f},
+ .aspect_ratio = a,
+ .time = t,
+ .beat = b,
+ .audio_intensity = i,
+ };
+ uniforms_.update(ctx_.queue, u);
+ wgpuRenderPassEncoderSetPipeline(pass, pass_.pipeline);
+ wgpuRenderPassEncoderSetBindGroup(pass, 0, pass_.bind_group, 0, nullptr);
+ wgpuRenderPassEncoderDraw(pass, pass_.vertex_count, 1, 0, 0);
+}