summaryrefslogtreecommitdiff
path: root/src/gpu/effects/circle_mask_effect.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-08 21:58:49 +0100
committerskal <pascal.massimino@gmail.com>2026-02-08 21:58:49 +0100
commit86e56474d284944795f4c02ae850561374620f8a (patch)
tree7ce0b35539e6c632024dd57cf1dafaef90aae487 /src/gpu/effects/circle_mask_effect.h
parentd3a609fad91744c45f6bc59b625a26f8870e271d (diff)
feat: Add CircleMaskEffect and RotatingCubeEffect with auxiliary texture masking
Implements demonstration of auxiliary texture masking system with: - CircleMaskEffect: Generates circular mask, renders green outside circle - RotatingCubeEffect: Renders SDF cube inside circle using mask Architecture: - Mask generation in compute phase (1.0 inside, 0.0 outside) - CircleMask renders green where mask < 0.5 (outside circle) - RotatingCube samples mask and discards where mask < 0.5 Files added: - src/gpu/effects/circle_mask_effect.{h,cc} - src/gpu/effects/rotating_cube_effect.{h,cc} - assets/final/shaders/{circle_mask_compute,circle_mask_render,masked_cube}.wgsl Build system: - Updated CMakeLists.txt with new effect sources - Registered shaders in demo_assets.txt - Updated test_demo_effects.cc (8 scene effects total) Status: Effects temporarily disabled in demo.seq (lines 31-35) - ShaderComposer snippet registration needed for masked_cube.wgsl - All 33 tests pass, demo runs without crashes Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/gpu/effects/circle_mask_effect.h')
-rw-r--r--src/gpu/effects/circle_mask_effect.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/gpu/effects/circle_mask_effect.h b/src/gpu/effects/circle_mask_effect.h
new file mode 100644
index 0000000..57f2389
--- /dev/null
+++ b/src/gpu/effects/circle_mask_effect.h
@@ -0,0 +1,50 @@
+// This file is part of the 64k demo project.
+// It defines the CircleMaskEffect class for masking system demonstration.
+// Creates a circular mask and renders green outside the circle.
+
+#ifndef CIRCLE_MASK_EFFECT_H_
+#define CIRCLE_MASK_EFFECT_H_
+
+#include "gpu/effect.h"
+#include "gpu/uniform_helper.h"
+
+class CircleMaskEffect : public Effect {
+ public:
+ CircleMaskEffect(const GpuContext& ctx, float radius = 0.4f);
+ ~CircleMaskEffect() override;
+
+ void init(MainSequence* demo) override;
+ void compute(WGPUCommandEncoder encoder, float time, float beat,
+ float intensity, float aspect_ratio) override;
+ void render(WGPURenderPassEncoder pass, float time, float beat,
+ float intensity, float aspect_ratio) override;
+
+ private:
+ struct ComputeUniforms {
+ float radius;
+ float aspect_ratio;
+ float width;
+ float height;
+ };
+
+ struct RenderUniforms {
+ float width;
+ float height;
+ float _pad1;
+ float _pad2;
+ };
+
+ MainSequence* demo_ = nullptr;
+ float radius_;
+
+ WGPURenderPipeline compute_pipeline_ = nullptr;
+ WGPUBindGroup compute_bind_group_ = nullptr;
+ UniformBuffer<ComputeUniforms> compute_uniforms_;
+
+ WGPURenderPipeline render_pipeline_ = nullptr;
+ WGPUBindGroup render_bind_group_ = nullptr;
+ WGPUSampler mask_sampler_ = nullptr;
+ UniformBuffer<RenderUniforms> render_uniforms_;
+};
+
+#endif /* CIRCLE_MASK_EFFECT_H_ */