summaryrefslogtreecommitdiff
path: root/src/3d/renderer.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-06 06:51:16 +0100
committerskal <pascal.massimino@gmail.com>2026-02-06 06:51:16 +0100
commitb68c8d8cbe9274e42a89888186152d4ded1a2962 (patch)
tree0d0d64ecaad2dadd29a4eff3daeb96867437d1ae /src/3d/renderer.h
parent32a6d4f516b2ff45e25ddc7870e5400c2973fb9a (diff)
feat(3d): Implement basic OBJ mesh asset pipeline
Added support for loading and rendering OBJ meshes. - Updated asset_packer to parse .obj files into a binary format. - Added MeshAsset and GetMeshAsset helper to asset_manager. - Extended Object3D with mesh_asset_id and ObjectType::MESH. - Implemented mesh rasterization pipeline in Renderer3D. - Added a sample cube mesh and verified in test_3d_render.
Diffstat (limited to 'src/3d/renderer.h')
-rw-r--r--src/3d/renderer.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/3d/renderer.h b/src/3d/renderer.h
index db86b72..5caf19b 100644
--- a/src/3d/renderer.h
+++ b/src/3d/renderer.h
@@ -8,6 +8,7 @@
#include "3d/scene.h"
#include "3d/bvh.h"
#include "gpu/gpu.h"
+#include <map>
#include <vector>
#if !defined(STRIP_ALL)
@@ -65,11 +66,19 @@ class Renderer3D {
void SetBvhEnabled(bool enabled) { bvh_enabled_ = enabled; }
private:
+ struct MeshGpuData {
+ WGPUBuffer vertex_buffer;
+ WGPUBuffer index_buffer;
+ uint32_t num_indices;
+ };
+
void create_pipeline();
WGPURenderPipeline create_pipeline_impl(bool use_bvh);
+ void create_mesh_pipeline();
void create_skybox_pipeline();
void create_default_resources();
void update_uniforms(const Scene& scene, const Camera& camera, float time);
+ const MeshGpuData* get_or_create_mesh(AssetId asset_id);
WGPUDevice device_ = nullptr;
WGPUQueue queue_ = nullptr;
@@ -78,6 +87,7 @@ class Renderer3D {
WGPURenderPipeline pipeline_ = nullptr; // BVH enabled
WGPURenderPipeline pipeline_no_bvh_ = nullptr; // BVH disabled
WGPUBindGroup bind_group_ = nullptr;
+ WGPURenderPipeline mesh_pipeline_ = nullptr;
WGPURenderPipeline skybox_pipeline_ = nullptr;
WGPUBindGroup skybox_bind_group_ = nullptr;
WGPUBuffer global_uniform_buffer_ = nullptr;
@@ -87,6 +97,8 @@ class Renderer3D {
BVH cpu_bvh_; // Keep a CPU-side copy for building/uploading
bool bvh_enabled_ = true;
+ std::map<AssetId, MeshGpuData> mesh_cache_;
+
WGPUTextureView noise_texture_view_ = nullptr;
WGPUTextureView sky_texture_view_ = nullptr;
WGPUSampler default_sampler_ = nullptr;