shithub: libgraphics

Download patch

ref: 5fa75a6d4b03c676112ca04cf5ff3f3ccd2f0fee
parent: 7739f20ce8608c0613552e430f31008705050bf1
author: rodri <rgl@antares-labs.eu>
date: Tue May 28 12:56:31 EDT 2024

add a normal map property to Material.

--- a/graphics.h
+++ b/graphics.h
@@ -108,6 +108,7 @@
 	Color specular;
 	double shininess;
 	Memimage *diffusemap;
+	Memimage *normalmap;
 };
 
 struct Primitive
--- a/scene.c
+++ b/scene.c
@@ -180,6 +180,13 @@
 				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);
 		}