diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-02 14:52:04 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-02 14:52:04 +0100 |
| commit | 9a57dabe1ae473fe35bafa2f80e2d7f1702c264b (patch) | |
| tree | 52e70ce9b603e0a84cc65a258354eb0e37a8dc20 /src/gpu | |
| parent | 43e257fab0ca544edbb36604a7871f96fd0142bf (diff) | |
feat(3d): Use procedural grid for floor and revert object noise
- Reverted test_3d_render to use the global 'noise' texture for floating objects, restoring their bump mapping.
- Implemented a procedural grid directly in the fragment shader for rasterized objects (floor).
- Inverted the grid color scheme (black lines on a lighter background) as requested.
- This ensures accurate object bump mapping and clear shadow visibility on the floor without requiring multiple texture bindings.
Diffstat (limited to 'src/gpu')
| -rw-r--r-- | src/gpu/effect.cc | 24 | ||||
| -rw-r--r-- | src/gpu/effect.h | 4 | ||||
| -rw-r--r-- | src/gpu/effects/hybrid_3d_effect.cc | 6 | ||||
| -rw-r--r-- | src/gpu/effects/hybrid_3d_effect.h | 1 |
4 files changed, 35 insertions, 0 deletions
diff --git a/src/gpu/effect.cc b/src/gpu/effect.cc index b2e0c4e..f115ac5 100644 --- a/src/gpu/effect.cc +++ b/src/gpu/effect.cc @@ -19,6 +19,12 @@ void PostProcessEffect::render(WGPURenderPassEncoder pass, float, float, float, } // --- Sequence Implementation --- +void Sequence::resize(int width, int height) { + for (SequenceItem& item : items_) { + item.effect->resize(width, height); + } +} + void Sequence::init(MainSequence* demo) { for (SequenceItem& item : items_) { if (!item.effect->is_initialized) { @@ -167,6 +173,24 @@ void MainSequence::add_sequence(std::shared_ptr<Sequence> seq, float start_time, }); } +void MainSequence::resize(int width, int height) { + // Release old resources + if (framebuffer_view_a_) wgpuTextureViewRelease(framebuffer_view_a_); + if (framebuffer_a_) wgpuTextureRelease(framebuffer_a_); + if (framebuffer_view_b_) wgpuTextureViewRelease(framebuffer_view_b_); + if (framebuffer_b_) wgpuTextureRelease(framebuffer_b_); + if (depth_view_) wgpuTextureViewRelease(depth_view_); + if (depth_texture_) wgpuTextureRelease(depth_texture_); + + // Recreate with new size + create_framebuffers(width, height); + + // Propagate to all sequences + for (ActiveSequence& entry : sequences_) { + entry.seq->resize(width, height); + } +} + void MainSequence::render_frame(float global_time, float beat, float peak, float aspect_ratio, WGPUSurface surface) { WGPUCommandEncoder encoder = wgpuDeviceCreateCommandEncoder(device, nullptr); diff --git a/src/gpu/effect.h b/src/gpu/effect.h index 29f8e85..e7453c7 100644 --- a/src/gpu/effect.h +++ b/src/gpu/effect.h @@ -33,6 +33,8 @@ class Effect { } virtual void render(WGPURenderPassEncoder pass, float time, float beat, float intensity, float aspect_ratio) = 0; + virtual void resize(int width, int height) {} + virtual void end() { } bool is_initialized = false; @@ -80,6 +82,7 @@ class Sequence { void add_effect(std::shared_ptr<Effect> effect, float start_time, float end_time, int priority = 0); void update_active_list(float seq_time); + void resize(int width, int height); void collect_active_effects(std::vector<SequenceItem*>& scene_effects, std::vector<SequenceItem*>& post_effects); void reset(); @@ -105,6 +108,7 @@ class MainSequence { int priority = 0); void render_frame(float global_time, float beat, float peak, float aspect_ratio, WGPUSurface surface); + void resize(int width, int height); void shutdown(); #if !defined(STRIP_ALL) diff --git a/src/gpu/effects/hybrid_3d_effect.cc b/src/gpu/effects/hybrid_3d_effect.cc index 51dec52..af956cd 100644 --- a/src/gpu/effects/hybrid_3d_effect.cc +++ b/src/gpu/effects/hybrid_3d_effect.cc @@ -14,6 +14,12 @@ Hybrid3DEffect::Hybrid3DEffect(WGPUDevice device, WGPUQueue queue, (void)format; // Passed to base, not directly used here. } +void Hybrid3DEffect::resize(int width, int height) { + width_ = width; + height_ = height; + renderer_.resize(width_, height_); +} + void Hybrid3DEffect::init(MainSequence* demo) { (void)demo; WGPUTextureFormat format = diff --git a/src/gpu/effects/hybrid_3d_effect.h b/src/gpu/effects/hybrid_3d_effect.h index ef62883..8eedeb2 100644 --- a/src/gpu/effects/hybrid_3d_effect.h +++ b/src/gpu/effects/hybrid_3d_effect.h @@ -18,6 +18,7 @@ class Hybrid3DEffect : public Effect { void init(MainSequence* demo) override; void render(WGPURenderPassEncoder pass, float time, float beat, float intensity, float aspect_ratio) override; + void resize(int width, int height) override; private: Renderer3D renderer_; |
