[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26910] trunk/blender/source/blender/ render/intern/source/imagetexture.c: Fix very long render time when using a large filter size with the new

Brecht Van Lommel brecht at blender.org
Mon Feb 15 09:29:01 CET 2010


Revision: 26910
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26910
Author:   blendix
Date:     2010-02-15 09:29:01 +0100 (Mon, 15 Feb 2010)

Log Message:
-----------
Fix very long render time when using a large filter size with the new
image sample code. I've added a dumb clamping now of dxt/dyt, probably
could use a smarter solution but it's not likely to be noticeable.

Modified Paths:
--------------
    trunk/blender/source/blender/render/intern/source/imagetexture.c

Modified: trunk/blender/source/blender/render/intern/source/imagetexture.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/imagetexture.c	2010-02-15 08:17:57 UTC (rev 26909)
+++ trunk/blender/source/blender/render/intern/source/imagetexture.c	2010-02-15 08:29:01 UTC (rev 26910)
@@ -823,7 +823,7 @@
 
 // anisotropic filters, data struct used instead of long line of (possibly unused) func args
 typedef struct afdata_t {
-	float *dxt, *dyt;
+	float dxt[2], dyt[2];
 	int intpol, extflag;
 	// feline only
 	float majrad, minrad, theta;
@@ -840,8 +840,8 @@
 	int xsam = (int)(0.5f*sqrtf(ux*ux + uy*uy) + 0.5f);
 	int ysam = (int)(0.5f*sqrtf(vx*vx + vy*vy) + 0.5f);
 	const int minsam = AFD->intpol ? 2 : 4;
-	xsam = xsam < minsam ? minsam : xsam;
-	ysam = ysam < minsam ? minsam : ysam;
+	xsam = CLAMPIS(xsam, minsam, ibuf->x*2);
+	ysam = CLAMPIS(ysam, minsam, ibuf->y*2);
 	xsd = 1.f / xsam;
 	ysd = 1.f / ysam;
 	texr->tr = texr->tg = texr->tb = texr->ta = 0.f;
@@ -1297,11 +1297,21 @@
 		ibuf->rect += ibuf->x*ibuf->y;
 
 	// struct common data
-	AFD.dxt = dxt;
-	AFD.dyt = dyt;
+	copy_v2_v2(AFD.dxt, dxt);
+	copy_v2_v2(AFD.dyt, dyt);
 	AFD.intpol = intpol;
 	AFD.extflag = extflag;
 
+	// brecht: added stupid clamping here, large dx/dy can give very large
+	// filter sizes which take ages to render, it may be better to do this
+	// more intelligently later in the code .. probably it's not noticeable
+	if(AFD.dxt[0]*AFD.dxt[0] + AFD.dxt[1]*AFD.dxt[1] > 2.0f*2.0f) {
+		mul_v2_fl(AFD.dxt, 2.0f/len_v2(AFD.dxt));
+		mul_v2_fl(AFD.dyt, 2.0f/len_v2(AFD.dyt));
+	}
+	if(AFD.dyt[0]*AFD.dyt[0] + AFD.dyt[1]*AFD.dyt[1] > 2.0f*2.0f)
+		mul_v2_fl(AFD.dyt, 2.0f/len_v2(AFD.dyt));
+
 	// choice:
 	if (tex->imaflag & TEX_MIPMAP) {
 		ImBuf *previbuf, *curibuf;





More information about the Bf-blender-cvs mailing list