summaryrefslogtreecommitdiff
path: root/src/effects/circle_mask_effect.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/effects/circle_mask_effect.h')
-rw-r--r--src/effects/circle_mask_effect.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/effects/circle_mask_effect.h b/src/effects/circle_mask_effect.h
new file mode 100644
index 0000000..53cc1bc
--- /dev/null
+++ b/src/effects/circle_mask_effect.h
@@ -0,0 +1,44 @@
+// 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/post_process_helper.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 resize(int width, int height) override;
+ void compute(WGPUCommandEncoder encoder,
+ const CommonPostProcessUniforms& uniforms) override;
+ void render(WGPURenderPassEncoder pass,
+ const CommonPostProcessUniforms& uniforms) override;
+
+ private:
+ struct CircleMaskParams {
+ float radius;
+ float _pad[3];
+ };
+ static_assert(sizeof(CircleMaskParams) == 16,
+ "CircleMaskParams must be 16 bytes for WGSL alignment");
+
+ MainSequence* demo_ = nullptr;
+ float radius_;
+
+ WGPURenderPipeline compute_pipeline_ = nullptr;
+ WGPUBindGroup compute_bind_group_ = nullptr;
+ UniformBuffer<CircleMaskParams> compute_params_;
+
+ WGPURenderPipeline render_pipeline_ = nullptr;
+ WGPUBindGroup render_bind_group_ = nullptr;
+ WGPUSampler mask_sampler_ = nullptr;
+};
+
+#endif /* CIRCLE_MASK_EFFECT_H_ */