summaryrefslogtreecommitdiff
path: root/src/gpu/effects
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/effects')
-rw-r--r--src/gpu/effects/fade_effect.cc7
-rw-r--r--src/gpu/effects/flash_effect.cc9
-rw-r--r--src/gpu/effects/shaders.cc6
-rw-r--r--src/gpu/effects/theme_modulation_effect.cc17
-rw-r--r--src/gpu/effects/theme_modulation_effect.h5
5 files changed, 26 insertions, 18 deletions
diff --git a/src/gpu/effects/fade_effect.cc b/src/gpu/effects/fade_effect.cc
index 3b942c0..4d7633c 100644
--- a/src/gpu/effects/fade_effect.cc
+++ b/src/gpu/effects/fade_effect.cc
@@ -47,15 +47,16 @@ FadeEffect::FadeEffect(WGPUDevice device, WGPUQueue queue,
)";
pipeline_ = create_post_process_pipeline(device, format, shader_code);
- uniforms_ = gpu_create_buffer(device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst);
+ uniforms_ = gpu_create_buffer(
+ device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst);
}
void FadeEffect::update_bind_group(WGPUTextureView input_view) {
pp_update_bind_group(device_, pipeline_, &bind_group_, input_view, uniforms_);
}
-void FadeEffect::render(WGPURenderPassEncoder pass, float time,
- float beat, float intensity, float aspect_ratio) {
+void FadeEffect::render(WGPURenderPassEncoder pass, float time, float beat,
+ float intensity, float aspect_ratio) {
(void)beat;
(void)intensity;
(void)aspect_ratio;
diff --git a/src/gpu/effects/flash_effect.cc b/src/gpu/effects/flash_effect.cc
index de7be62..176c60c 100644
--- a/src/gpu/effects/flash_effect.cc
+++ b/src/gpu/effects/flash_effect.cc
@@ -49,22 +49,23 @@ FlashEffect::FlashEffect(WGPUDevice device, WGPUQueue queue,
)";
pipeline_ = create_post_process_pipeline(device, format, shader_code);
- uniforms_ = gpu_create_buffer(device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst);
+ uniforms_ = gpu_create_buffer(
+ device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst);
}
void FlashEffect::update_bind_group(WGPUTextureView input_view) {
pp_update_bind_group(device_, pipeline_, &bind_group_, input_view, uniforms_);
}
-void FlashEffect::render(WGPURenderPassEncoder pass, float time,
- float beat, float intensity, float aspect_ratio) {
+void FlashEffect::render(WGPURenderPassEncoder pass, float time, float beat,
+ float intensity, float aspect_ratio) {
(void)time;
(void)beat;
(void)aspect_ratio;
// Trigger flash on strong beat hits
if (intensity > 0.7f && flash_intensity_ < 0.2f) {
- flash_intensity_ = 0.8f; // Trigger flash
+ flash_intensity_ = 0.8f; // Trigger flash
}
// Exponential decay
diff --git a/src/gpu/effects/shaders.cc b/src/gpu/effects/shaders.cc
index 7255cf5..7b543e1 100644
--- a/src/gpu/effects/shaders.cc
+++ b/src/gpu/effects/shaders.cc
@@ -34,8 +34,10 @@ void InitShaderComposer() {
register_if_exists("math/sdf_shapes", AssetId::ASSET_SHADER_MATH_SDF_SHAPES);
register_if_exists("math/sdf_utils", AssetId::ASSET_SHADER_MATH_SDF_UTILS);
register_if_exists("render/shadows", AssetId::ASSET_SHADER_RENDER_SHADOWS);
- register_if_exists("render/scene_query", AssetId::ASSET_SHADER_RENDER_SCENE_QUERY);
- register_if_exists("render/lighting_utils", AssetId::ASSET_SHADER_RENDER_LIGHTING_UTILS);
+ register_if_exists("render/scene_query",
+ AssetId::ASSET_SHADER_RENDER_SCENE_QUERY);
+ register_if_exists("render/lighting_utils",
+ AssetId::ASSET_SHADER_RENDER_LIGHTING_UTILS);
register_if_exists("sdf_primitives", AssetId::ASSET_SHADER_SDF_PRIMITIVES);
diff --git a/src/gpu/effects/theme_modulation_effect.cc b/src/gpu/effects/theme_modulation_effect.cc
index 4ddb1f4..d2705d5 100644
--- a/src/gpu/effects/theme_modulation_effect.cc
+++ b/src/gpu/effects/theme_modulation_effect.cc
@@ -51,7 +51,8 @@ ThemeModulationEffect::ThemeModulationEffect(WGPUDevice device, WGPUQueue queue,
pipeline_ = create_post_process_pipeline(device, format, shader_code);
// Create uniform buffer (4 floats: brightness + padding)
- uniforms_ = gpu_create_buffer(device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst);
+ uniforms_ = gpu_create_buffer(
+ device, 16, WGPUBufferUsage_Uniform | WGPUBufferUsage_CopyDst);
}
void ThemeModulationEffect::update_bind_group(WGPUTextureView input_view) {
@@ -59,22 +60,24 @@ void ThemeModulationEffect::update_bind_group(WGPUTextureView input_view) {
}
void ThemeModulationEffect::render(WGPURenderPassEncoder pass, float time,
- float beat, float intensity,
- float aspect_ratio) {
+ float beat, float intensity,
+ float aspect_ratio) {
(void)beat;
(void)intensity;
(void)aspect_ratio;
// Alternate between bright and dark every 4 seconds (2 pattern changes)
// Music patterns change every 2 seconds at 120 BPM
- float cycle_time = fmodf(time, 8.0f); // 8 second cycle (4 patterns)
- bool is_dark_section = (cycle_time >= 4.0f); // Dark for second half
+ float cycle_time = fmodf(time, 8.0f); // 8 second cycle (4 patterns)
+ bool is_dark_section = (cycle_time >= 4.0f); // Dark for second half
// Smooth transition between themes using a sine wave
- float transition = (std::sin(time * 3.14159f / 4.0f) + 1.0f) * 0.5f; // 0.0 to 1.0
+ float transition =
+ (std::sin(time * 3.14159f / 4.0f) + 1.0f) * 0.5f; // 0.0 to 1.0
float bright_value = 1.0f;
float dark_value = 0.35f;
- float theme_brightness = bright_value + (dark_value - bright_value) * transition;
+ float theme_brightness =
+ bright_value + (dark_value - bright_value) * transition;
// Update uniform buffer
float uniforms[4] = {theme_brightness, 0.0f, 0.0f, 0.0f};
diff --git a/src/gpu/effects/theme_modulation_effect.h b/src/gpu/effects/theme_modulation_effect.h
index 6f76695..ac584e2 100644
--- a/src/gpu/effects/theme_modulation_effect.h
+++ b/src/gpu/effects/theme_modulation_effect.h
@@ -1,6 +1,7 @@
// This file is part of the 64k demo project.
-// It implements a theme modulation effect that alternates between bright and dark.
-// Pattern changes every 2 seconds, so we alternate every 4 seconds (2 patterns).
+// It implements a theme modulation effect that alternates between bright and
+// dark. Pattern changes every 2 seconds, so we alternate every 4 seconds (2
+// patterns).
#pragma once
#include "gpu/effect.h"