[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28048] branches/render25/source/blender/ render/intern/source/texture_stack.c: Fix texture node image textures not getting correct derivatives for filtering .

Brecht Van Lommel brecht at blender.org
Tue Apr 6 16:41:40 CEST 2010


Revision: 28048
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28048
Author:   blendix
Date:     2010-04-06 16:41:40 +0200 (Tue, 06 Apr 2010)

Log Message:
-----------
Fix texture node image textures not getting correct derivatives for filtering.

Modified Paths:
--------------
    branches/render25/source/blender/render/intern/source/texture_stack.c

Modified: branches/render25/source/blender/render/intern/source/texture_stack.c
===================================================================
--- branches/render25/source/blender/render/intern/source/texture_stack.c	2010-04-06 10:24:57 UTC (rev 28047)
+++ branches/render25/source/blender/render/intern/source/texture_stack.c	2010-04-06 14:41:40 UTC (rev 28048)
@@ -89,7 +89,7 @@
 {
 	Tex *tex= mtex->tex;
 
-	if(tex->use_nodes && tex->nodetree) {
+	if(tex->type == TEX_NODES && tex->nodetree) {
 		/* stupid exception here .. but we have to pass shi and mtex to
 		   textures nodes for 2d mapping and color management for images */
 		return ntreeTexExecTree(tex->nodetree, texres, co, dx, dy, shi->geometry.osatex, shi->shading.thread,
@@ -233,7 +233,7 @@
 
 /* ------------------------------------------------------------------------- */
 
-static void do_2d_mapping(Render *re, MTex *mtex, float *t, ObjectRen *obr, VlakRen *vlr, float *n, float *dxt, float *dyt)
+static void do_2d_mapping(Render *re, MTex *mtex, float *t, ObjectRen *obr, VlakRen *vlr, float *n, float *dxt, float *dyt, int osa)
 {
 	Tex *tex;
 	Object *ob= NULL;
@@ -246,7 +246,7 @@
 	ob= mtex->object;
 	texco= mtex->texco;
 
-	if(re->params.osa==0) {
+	if(osa==0) {
 		
 		if(wrap==MTEX_FLAT) {
 			fx = (t[0] + 1.0) / 2.0;
@@ -695,7 +695,7 @@
 			}
 			else dxt[2] = dyt[2] = 0.f;
 		}
-		do_2d_mapping(re, mtex, texvec, shi->primitive.obr, shi->primitive.vlr, shi->geometry.facenor, dxt, dyt);
+		do_2d_mapping(re, mtex, texvec, shi->primitive.obr, shi->primitive.vlr, shi->geometry.facenor, dxt, dyt, re->params.r.osa);
 
 		// translate and scale
 		texvec[0] = mtex->size[0]*(texvec[0] - 0.5f) + mtex->ofs[0] + 0.5f;
@@ -732,7 +732,12 @@
 		}
 		
 	}
-	else {	// procedural
+	else if (tex->type == TEX_NODES) {
+		copy_v3_v3(texvec, co);
+		copy_v3_v3(dxt, dx);
+		copy_v3_v3(dyt, dy);
+	}
+	else { /* procedural */
 		// placement
 		texvec[0] = mtex->size[0]*(mtex->projx ? (co[mtex->projx - 1] + mtex->ofs[0]) : mtex->ofs[0]);
 		texvec[1] = mtex->size[1]*(mtex->projy ? (co[mtex->projy - 1] + mtex->ofs[1]) : mtex->ofs[1]);
@@ -1474,7 +1479,7 @@
 			
 			if(tex->type==TEX_IMAGE) {
 				continue;	/* not supported yet */				
-				//do_2d_mapping(re, mtex, texvec, NULL, NULL, NULL, dxt, dyt);
+				//do_2d_mapping(re, mtex, texvec, NULL, NULL, NULL, dxt, dyt, re->params.r.osa);
 			}
 			else {
 				/* placement */
@@ -1650,7 +1655,7 @@
 
 	}
 
-	if(mtex->tex->type==TEX_IMAGE) do_2d_mapping(re, mtex, texvec, NULL, NULL, NULL, dxt, dyt);
+	if(mtex->tex->type==TEX_IMAGE) do_2d_mapping(re, mtex, texvec, NULL, NULL, NULL, dxt, dyt, re->params.r.osa);
 	
 	rgb= tex_sample_old(&re->params, mtex->tex, texvec, dxt, dyt, osatex, &texres, 0, mtex->which_output);
 
@@ -1833,7 +1838,7 @@
 			else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
 			
 			/* texture */
-			if(tex->type==TEX_IMAGE) do_2d_mapping(re, mtex, texvec, NULL, NULL, NULL, dxt, dyt);
+			if(tex->type==TEX_IMAGE) do_2d_mapping(re, mtex, texvec, NULL, NULL, NULL, dxt, dyt, re->params.r.osa);
 		
 			rgb= tex_sample_old(&re->params, mtex->tex, texvec, dxt, dyt, re->params.osa, &texres, thread, mtex->which_output);
 			
@@ -2035,7 +2040,7 @@
 			
 			/* texture */
 			if(tex->type==TEX_IMAGE) {
-				do_2d_mapping(re, mtex, texvec, NULL, NULL, NULL, dxt, dyt);
+				do_2d_mapping(re, mtex, texvec, NULL, NULL, NULL, dxt, dyt, re->params.r.osa);
 			}
 			
 			rgb= tex_sample_old(&re->params, tex, texvec, dxt, dyt, shi->geometry.osatex, &texres, shi->shading.thread, mtex->which_output);
@@ -2180,7 +2185,7 @@
 
 		if(mtex) {
 			/* we have mtex, use it for 2d mapping images only */
-			do_2d_mapping(&re, mtex, texvec, shi->primitive.obr, shi->primitive.vlr, shi->geometry.facenor, dxt, dyt);
+			do_2d_mapping(&re, mtex, texvec, shi->primitive.obr, shi->primitive.vlr, shi->geometry.facenor, dxt, dyt, shi->geometry.osatex);
 			rgbnor= tex_sample_old(&re.params, tex, texvec, dxt, dyt, osatex, texres, thread, which_output);
 
 			if(mtex->mapto & (MAP_COL+MAP_COLSPEC+MAP_COLMIR)) {
@@ -2211,7 +2216,7 @@
 				zero_v3(dyt_l);
 			}
 			
-			do_2d_mapping(&re, &localmtex, texvec_l, NULL, NULL, NULL, dxt_l, dyt_l);
+			do_2d_mapping(&re, &localmtex, texvec_l, NULL, NULL, NULL, dxt_l, dyt_l, (dxt && dyt));
 			rgbnor= tex_sample_old(&re.params, tex, texvec_l, dxt_l, dyt_l, osatex, texres, thread, which_output);
 		}
 
@@ -2251,10 +2256,13 @@
 	
 	if(mtex->projz) texvec[2]= mtex->size[2]*(vec[mtex->projz-1]+mtex->ofs[2]);
 	else texvec[2]= mtex->size[2]*(mtex->ofs[2]);
+
+	zero_v3(dxt);
+	zero_v3(dyt);
 	
 	/* texture */
 	if(tex->type==TEX_IMAGE) {
-		do_2d_mapping(&re, mtex, texvec, NULL, NULL, NULL, dxt, dyt);
+		do_2d_mapping(&re, mtex, texvec, NULL, NULL, NULL, dxt, dyt, 0);
 	}
 	
 	rgb= tex_sample_old(&re.params, tex, texvec, dxt, dyt, 0, &texr, 0, mtex->which_output);





More information about the Bf-blender-cvs mailing list