diff options
Diffstat (limited to 'src/gpu')
| -rw-r--r-- | src/gpu/demo_effects.h | 1 | ||||
| -rw-r--r-- | src/gpu/effects/scene1_effect.cc | 28 | ||||
| -rw-r--r-- | src/gpu/effects/scene1_effect.h | 19 | ||||
| -rw-r--r-- | src/gpu/effects/shaders.cc | 4 | ||||
| -rw-r--r-- | src/gpu/effects/shaders.h | 1 |
5 files changed, 53 insertions, 0 deletions
diff --git a/src/gpu/demo_effects.h b/src/gpu/demo_effects.h index 72b3f65..1ccf930 100644 --- a/src/gpu/demo_effects.h +++ b/src/gpu/demo_effects.h @@ -15,6 +15,7 @@ #include "gpu/effects/theme_modulation_effect.h" // ThemeModulationEffect with full definition #include "gpu/effects/hybrid_3d_effect.h" #include "gpu/effects/flash_cube_effect.h" +#include "gpu/effects/scene1_effect.h" #include "gpu/gpu.h" #include "gpu/texture_manager.h" #include "gpu/uniform_helper.h" diff --git a/src/gpu/effects/scene1_effect.cc b/src/gpu/effects/scene1_effect.cc new file mode 100644 index 0000000..a6733b7 --- /dev/null +++ b/src/gpu/effects/scene1_effect.cc @@ -0,0 +1,28 @@ +// This file is part of the 64k demo project. +// Scene1 effect - ShaderToy conversion (raymarching scene) + +#include "gpu/demo_effects.h" +#include "gpu/gpu.h" + +Scene1Effect::Scene1Effect(const GpuContext& ctx) : Effect(ctx) { + ResourceBinding bindings[] = {{uniforms_.get(), WGPUBufferBindingType_Uniform}}; + pass_ = gpu_create_render_pass(ctx_.device, ctx_.format, scene1_shader_wgsl, + bindings, 1); + pass_.vertex_count = 3; +} + +void Scene1Effect::render(WGPURenderPassEncoder pass, float t, float b, + float i, float a) { + CommonPostProcessUniforms u = { + .resolution = {(float)width_, (float)height_}, + ._pad = {0.0f, 0.0f}, + .aspect_ratio = a, + .time = t, + .beat = b, + .audio_intensity = i, + }; + uniforms_.update(ctx_.queue, u); + wgpuRenderPassEncoderSetPipeline(pass, pass_.pipeline); + wgpuRenderPassEncoderSetBindGroup(pass, 0, pass_.bind_group, 0, nullptr); + wgpuRenderPassEncoderDraw(pass, pass_.vertex_count, 1, 0, 0); +} diff --git a/src/gpu/effects/scene1_effect.h b/src/gpu/effects/scene1_effect.h new file mode 100644 index 0000000..dc5c747 --- /dev/null +++ b/src/gpu/effects/scene1_effect.h @@ -0,0 +1,19 @@ +// This file is part of the 64k demo project. +// Scene1 effect - ShaderToy conversion (raymarching scene) + +#ifndef SCENE1_EFFECT_H_ +#define SCENE1_EFFECT_H_ + +#include "gpu/effect.h" + +class Scene1Effect : public Effect { + public: + Scene1Effect(const GpuContext& ctx); + void render(WGPURenderPassEncoder pass, float time, float beat, + float intensity, float aspect_ratio) override; + + private: + RenderPass pass_; +}; + +#endif /* SCENE1_EFFECT_H_ */ diff --git a/src/gpu/effects/shaders.cc b/src/gpu/effects/shaders.cc index 6559bf5..5f78298 100644 --- a/src/gpu/effects/shaders.cc +++ b/src/gpu/effects/shaders.cc @@ -98,6 +98,10 @@ const char* solarize_shader_wgsl = SafeGetAsset(AssetId::ASSET_SHADER_SOLARIZE); +const char* scene1_shader_wgsl = + + SafeGetAsset(AssetId::ASSET_SHADER_SCENE1); + const char* distort_shader_wgsl = SafeGetAsset(AssetId::ASSET_SHADER_DISTORT); diff --git a/src/gpu/effects/shaders.h b/src/gpu/effects/shaders.h index 7acc2a6..03fa48c 100644 --- a/src/gpu/effects/shaders.h +++ b/src/gpu/effects/shaders.h @@ -15,6 +15,7 @@ extern const char* ellipse_shader_wgsl; extern const char* particle_spray_compute_wgsl; extern const char* gaussian_blur_shader_wgsl; extern const char* solarize_shader_wgsl; +extern const char* scene1_shader_wgsl; extern const char* distort_shader_wgsl; extern const char* chroma_aberration_shader_wgsl; extern const char* vignette_shader_wgsl; |
