diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-17 13:24:56 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-17 13:24:56 +0100 |
| commit | e3f0b002c0998c8553e782273b254869107ffc0f (patch) | |
| tree | e1e5f8a6c5d119e7764d8d7a43b43bc0c65f4e78 | |
| parent | bdb1a4e95a545f3f4d88630b8aec6ab771776d99 (diff) | |
feat(uniforms): Add noise field with per-frame random values
Replace _pad with noise field in UniformsSequenceParams, providing
effects with non-deterministic random values [0..1] updated each frame.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
| -rw-r--r-- | common/shaders/sequence_uniforms.wgsl | 2 | ||||
| -rw-r--r-- | src/gpu/sequence.cc | 7 | ||||
| -rw-r--r-- | src/gpu/sequence.h | 2 | ||||
| -rw-r--r-- | tools/cnn_test.cc | 2 |
4 files changed, 9 insertions, 4 deletions
diff --git a/common/shaders/sequence_uniforms.wgsl b/common/shaders/sequence_uniforms.wgsl index be47ad9..290f89b 100644 --- a/common/shaders/sequence_uniforms.wgsl +++ b/common/shaders/sequence_uniforms.wgsl @@ -8,5 +8,5 @@ struct UniformsSequenceParams { beat_time: f32, beat_phase: f32, audio_intensity: f32, - _pad: f32, + noise: f32, }; diff --git a/src/gpu/sequence.cc b/src/gpu/sequence.cc index 901d560..9de4133 100644 --- a/src/gpu/sequence.cc +++ b/src/gpu/sequence.cc @@ -4,6 +4,7 @@ #include "gpu/effect.h" #include "util/fatal_error.h" #include <algorithm> +#include <random> // NodeRegistry implementation @@ -227,7 +228,11 @@ void Sequence::preprocess(float seq_time, float beat_time, float beat_phase, params_.beat_time = beat_time; params_.beat_phase = beat_phase; params_.audio_intensity = audio_intensity; - params_._pad = 0.0f; + + static std::random_device rd; + static std::mt19937 gen(rd()); + static std::uniform_real_distribution<float> dis(0.0f, 1.0f); + params_.noise = dis(gen); uniforms_buffer_.update(ctx_.queue, params_); } diff --git a/src/gpu/sequence.h b/src/gpu/sequence.h index 3bb770f..2ad0a8f 100644 --- a/src/gpu/sequence.h +++ b/src/gpu/sequence.h @@ -38,7 +38,7 @@ struct UniformsSequenceParams { float beat_time; // Musical beats float beat_phase; // Fractional beat 0.0-1.0 float audio_intensity; - float _pad; + float noise; // Random value [0..1] }; static_assert(sizeof(UniformsSequenceParams) == 32, "UniformsSequenceParams must be 32 bytes for WGSL alignment"); diff --git a/tools/cnn_test.cc b/tools/cnn_test.cc index 5694a62..1262021 100644 --- a/tools/cnn_test.cc +++ b/tools/cnn_test.cc @@ -1391,7 +1391,7 @@ int main(int argc, char** argv) { .beat_time = 0.0f, .beat_phase = 0.0f, .audio_intensity = 0.0f, - ._pad = 0.0f, + .noise = 0.0f, }; wgpuQueueWriteBuffer(queue, common_uniform_buffer, 0, &common_u, sizeof(common_u)); |
