From 9a57dabe1ae473fe35bafa2f80e2d7f1702c264b Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 2 Feb 2026 14:52:04 +0100 Subject: 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. --- src/gpu/effect.cc | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/gpu/effect.cc') 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 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); -- cgit v1.2.3