summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-05-28 16:56:31 +0000
committerrodri <rgl@antares-labs.eu>2024-05-28 16:56:31 +0000
commit5fa75a6d4b03c676112ca04cf5ff3f3ccd2f0fee (patch)
tree5cc54afbf965a81c5f101f27fec25d1700a9b4d2
parent7739f20ce8608c0613552e430f31008705050bf1 (diff)
downloadlibgraphics-5fa75a6d4b03c676112ca04cf5ff3f3ccd2f0fee.tar.gz
libgraphics-5fa75a6d4b03c676112ca04cf5ff3f3ccd2f0fee.tar.bz2
libgraphics-5fa75a6d4b03c676112ca04cf5ff3f3ccd2f0fee.zip
add a normal map property to Material.
-rw-r--r--graphics.h1
-rw-r--r--scene.c7
2 files changed, 8 insertions, 0 deletions
diff --git a/graphics.h b/graphics.h
index 90a79dd..7eded0e 100644
--- a/graphics.h
+++ b/graphics.h
@@ -108,6 +108,7 @@ struct Material
Color specular;
double shininess;
Memimage *diffusemap;
+ Memimage *normalmap;
};
struct Primitive
diff --git a/scene.c b/scene.c
index 15d3cc0..c9c8d5c 100644
--- a/scene.c
+++ b/scene.c
@@ -180,6 +180,13 @@ loadobjmodel(Model *m, OBJ *obj)
mtl->diffusemap->data->ref++;
}
+ if(objmtl->norm != nil){
+ mtl->normalmap = allocmemimaged(objmtl->norm->r, objmtl->norm->chan, objmtl->norm->data);
+ if(mtl->normalmap == nil)
+ sysfatal("allocmemimaged: %r");
+ mtl->normalmap->data->ref++;
+ }
+
addmtlmap(&mtlmap, objmtl, m->nmaterials-1);
}