From d26100734623f37063206b9b144c2a29fd71d414 Mon Sep 17 00:00:00 2001 From: quou Date: Wed, 1 Jan 2025 18:43:31 +1100 Subject: material system --- model.hpp | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) (limited to 'model.hpp') diff --git a/model.hpp b/model.hpp index 03cdef4..0dd8c43 100644 --- a/model.hpp +++ b/model.hpp @@ -5,13 +5,31 @@ #include "maths.hpp" #include "video.hpp" +struct Material : public Asset { + float metalness, roughness, ao; + v3f albedo; + struct { + Texture_Id albedo; + Texture_Id ao; + Texture_Id metal; + Texture_Id rough; + Texture_Id normal; + } tex; + void use( + Pipeline_Builder& pb, + Sampler_Id sampler, + Shader& shader + ); +}; + struct Model; struct Mesh { int offset, vbo_offset, count; - int parent, mesh_binding, mvp_binding; + int parent, mesh_binding, mvp_binding, mat_binding; bool world_dirty; m4f local, world; Shader_Id shader; + Material* material; const m4f& get_world(Model& m); }; @@ -19,6 +37,7 @@ struct Model : public Asset { Buffer_Id vbo; Buffer_Id ibo; Buffer_Id mvp; + Buffer_Id mat; int mesh_count; Mesh* get_meshes() { @@ -35,7 +54,8 @@ struct Model : public Asset { void render( Device* dev, Arena* a, - Render_Pass& pass + Render_Pass& pass, + Sampler_Id sampler ); }; @@ -49,7 +69,20 @@ struct Model_Loader : public Asset_Loader { const char* filename, Pack_File* f ) override; - void unload(Asset* a); + void unload(Asset* a) override; +}; + +struct Material_Loader : public Asset_Loader { + Asset_Arena* textures; + Texture_Id default_tex; + void init(Asset_Arena* texture_arena, Texture_Id dt); + Asset* load( + Arena* a, + Arena* s, + const char* filename, + Pack_File* f + ) override; + void unload(Asset* a) override; }; #endif -- cgit v1.2.3-54-g00ecf