shithub: 3dee

Download patch

ref: 4605adef59010fa2ed74b862e8169baf73680bf4
parent: f8954cf69e723da397c9ddd3cedf6a2a039668eb
author: rodri <rgl@antares-labs.eu>
date: Fri Aug 16 09:56:17 EDT 2024

let Model.tex have precedence over any material.

--- a/med.c
+++ b/med.c
@@ -280,10 +280,10 @@
 {
 	Color tc, c;
 
-	if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
-		tc = sampletexture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
-	else if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
+	if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
 		tc = sampletexture(sp->su->entity->mdl->tex, sp->v.uv, tsampler);
+	else if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
+		tc = sampletexture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
 	else
 		tc = Pt3(1,1,1,1);
 
@@ -376,10 +376,10 @@
 	specular = mulpt3(lightc, spec*Ks);
 	specular = modulapt3(specular, m.specular);
 
-	if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
-		tc = sampletexture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
-	else if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
+	if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
 		tc = sampletexture(sp->su->entity->mdl->tex, sp->v.uv, tsampler);
+	else if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
+		tc = sampletexture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
 	else
 		tc = Pt3(1,1,1,1);
 
@@ -403,10 +403,10 @@
 {
 	Color tc, c;
 
-	if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
-		tc = sampletexture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
-	else if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
+	if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
 		tc = sampletexture(sp->su->entity->mdl->tex, sp->v.uv, tsampler);
+	else if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
+		tc = sampletexture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
 	else
 		tc = Pt3(1,1,1,1);
 
--- a/vis.c
+++ b/vis.c
@@ -165,10 +165,10 @@
 {
 	Color tc;
 
-	if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
-		tc = sampletexture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
-	else if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
+	if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
 		tc = sampletexture(sp->su->entity->mdl->tex, sp->v.uv, tsampler);
+	else if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
+		tc = sampletexture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
 	else
 		tc = Pt3(1,1,1,1);
 
@@ -262,10 +262,10 @@
 	specular = mulpt3(lightc, spec*Ks);
 	specular = modulapt3(specular, m.specular);
 
-	if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
-		tc = sampletexture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
-	else if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
+	if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
 		tc = sampletexture(sp->su->entity->mdl->tex, sp->v.uv, tsampler);
+	else if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
+		tc = sampletexture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
 	else
 		tc = Pt3(1,1,1,1);
 
@@ -321,10 +321,10 @@
 {
 	Color tc;
 
-	if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
-		tc = sampletexture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
-	else if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
+	if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
 		tc = sampletexture(sp->su->entity->mdl->tex, sp->v.uv, tsampler);
+	else if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
+		tc = sampletexture(sp->v.mtl->diffusemap, sp->v.uv, tsampler);
 	else
 		tc = Pt3(1,1,1,1);