blob: 824155786a7d48dca655ac1bbaace572d4bf623a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
// This file is part of the 64k demo project.
// It declares the FlashEffect - brief white flash on beat hits.
#pragma once
#include "gpu/effect.h"
#include "gpu/gpu.h"
#include "gpu/uniform_helper.h"
// Parameters for FlashEffect (set at construction time)
struct FlashEffectParams {
float color[3] = {1.0f, 1.0f, 1.0f}; // Default: white
float decay_rate = 0.98f; // Default: fast decay
float trigger_threshold = 0.7f; // Default: trigger on strong beats
};
// Uniform data sent to GPU shader
struct FlashUniforms {
float flash_intensity;
float intensity;
float color[3]; // RGB flash color
float _pad;
};
class FlashEffect : public PostProcessEffect {
public:
// Backward compatibility constructor (uses default params)
FlashEffect(const GpuContext& ctx);
// New parameterized constructor
FlashEffect(const GpuContext& ctx, const FlashEffectParams& params);
void render(WGPURenderPassEncoder pass, float time, float beat,
float intensity, float aspect_ratio) override;
void update_bind_group(WGPUTextureView input_view) override;
private:
FlashEffectParams params_;
UniformBuffer<FlashUniforms> uniforms_;
float flash_intensity_ = 0.0f;
};
|