summaryrefslogtreecommitdiff
path: root/src/gpu
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-01 11:31:00 +0100
committerskal <pascal.massimino@gmail.com>2026-02-01 11:31:00 +0100
commitf80e37bd61e447f1d66fbb5eb4c1ab7a8a77cf0f (patch)
treed6c06e4c9e6d2570458d88d35acba9e64231cbc0 /src/gpu
parentf307cde4ac1126e38c5595ce61a26d50cdd7ad4a (diff)
feat: Add seamless bump mapping with procedural noise
- Replaced white noise with smooth value-like noise. - Implemented periodic texture generation (seam blending). - Integrated bump mapping into Renderer3D using finite difference of displaced SDF. - Updated test_3d_render with noise texture and multiple SDF shapes (Box, Sphere, Torus).
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/gpu.h11
-rw-r--r--src/gpu/texture_manager.cc6
2 files changed, 8 insertions, 9 deletions
diff --git a/src/gpu/gpu.h b/src/gpu/gpu.h
index b71e144..9ed1913 100644
--- a/src/gpu/gpu.h
+++ b/src/gpu/gpu.h
@@ -111,12 +111,13 @@ struct ResourceBinding {
};
// Cross-platform helper for color attachment initialization
-inline void gpu_init_color_attachment(WGPURenderPassColorAttachment& attachment, WGPUTextureView view) {
- attachment.view = view;
- attachment.loadOp = WGPULoadOp_Clear;
- attachment.storeOp = WGPUStoreOp_Store;
+inline void gpu_init_color_attachment(WGPURenderPassColorAttachment& attachment,
+ WGPUTextureView view) {
+ attachment.view = view;
+ attachment.loadOp = WGPULoadOp_Clear;
+ attachment.storeOp = WGPUStoreOp_Store;
#if !defined(DEMO_CROSS_COMPILE_WIN32)
- attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
+ attachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
#endif
}
diff --git a/src/gpu/texture_manager.cc b/src/gpu/texture_manager.cc
index 7c314d2..4240245 100644
--- a/src/gpu/texture_manager.cc
+++ b/src/gpu/texture_manager.cc
@@ -40,8 +40,7 @@ void TextureManager::create_procedural_texture(
// 2. Create GPU Texture
WGPUTextureDescriptor tex_desc = {};
- tex_desc.usage =
- WGPUTextureUsage_TextureBinding | WGPUTextureUsage_CopyDst;
+ tex_desc.usage = WGPUTextureUsage_TextureBinding | WGPUTextureUsage_CopyDst;
tex_desc.dimension = WGPUTextureDimension_2D;
tex_desc.size = tex_size;
tex_desc.format = WGPUTextureFormat_RGBA8Unorm;
@@ -70,7 +69,6 @@ void TextureManager::create_procedural_texture(
wgpuQueueWriteTexture(queue_, &destination, pixel_data.data(),
pixel_data.size(), &source_layout, &tex_size);
-
// 4. Create View
WGPUTextureViewDescriptor view_desc = {};
view_desc.format = WGPUTextureFormat_RGBA8Unorm;
@@ -89,7 +87,7 @@ void TextureManager::create_procedural_texture(
gpu_tex.view = view;
gpu_tex.width = def.width;
gpu_tex.height = def.height;
-
+
textures_[name] = gpu_tex;
#if !defined(STRIP_ALL)