summaryrefslogtreecommitdiff
path: root/model.hpp
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2025-01-01 18:43:31 +1100
committerquou <quou@disroot.org>2025-01-01 18:43:31 +1100
commitd26100734623f37063206b9b144c2a29fd71d414 (patch)
tree11aefe54b4110109a841cb656b2f309ee69a1893 /model.hpp
parent568ba73c71b650f905bd1b3f60f10871316eefdc (diff)
material system
Diffstat (limited to 'model.hpp')
-rw-r--r--model.hpp39
1 files changed, 36 insertions, 3 deletions
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