[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49699] trunk/blender/source/blender: DOF node: clamp blurring the zdepth radius buffer by the blur max.

Campbell Barton ideasman42 at gmail.com
Wed Aug 8 18:14:58 CEST 2012


Revision: 49699
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49699
Author:   campbellbarton
Date:     2012-08-08 16:14:56 +0000 (Wed, 08 Aug 2012)
Log Message:
-----------
DOF node: clamp blurring the zdepth radius buffer by the blur max. This could doo easily blur very high depths and cause artifacts.

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
    trunk/blender/source/blender/nodes/composite/nodes/node_composite_defocus.c

Modified: trunk/blender/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp	2012-08-08 16:03:42 UTC (rev 49698)
+++ trunk/blender/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp	2012-08-08 16:14:56 UTC (rev 49699)
@@ -53,9 +53,11 @@
 			normalize_m4(obmat);
 			invert_m4_m4(imat, obmat);
 			mult_m4_m4m4(mat, imat, camera->dof_ob->obmat);
-			return (float)fabs(mat[3][2]);
+			return fabsf(mat[3][2]);
 		}
-		return camera->YF_dofdist;
+		else {
+			return camera->YF_dofdist;
+		}
 	}
 }
 
@@ -71,7 +73,7 @@
 	this->m_dof_sp = (float)minsz / (16.f / this->m_cam_lens);    // <- == aspect * MIN2(img->x, img->y) / tan(0.5f * fov);
 	
 	if (this->m_blurPostOperation) {
-		m_blurPostOperation->setSigma(m_aperture * 128.0f);
+		m_blurPostOperation->setSigma(min(m_aperture * 128.0f, this->m_maxRadius));
 	}
 }
 

Modified: trunk/blender/source/blender/nodes/composite/nodes/node_composite_defocus.c
===================================================================
--- trunk/blender/source/blender/nodes/composite/nodes/node_composite_defocus.c	2012-08-08 16:03:42 UTC (rev 49698)
+++ trunk/blender/source/blender/nodes/composite/nodes/node_composite_defocus.c	2012-08-08 16:14:56 UTC (rev 49699)
@@ -166,17 +166,17 @@
 	// see "Recursive Gabor Filtering" by Young/VanVliet
 	// all factors here in double.prec. Required, because for single.prec it seems to blow up if sigma > ~200
 	if (sigma >= 3.556f)
-		q = 0.9804f*(sigma - 3.556f) + 2.5091f;
+		q = 0.9804f * (sigma - 3.556f) + 2.5091f;
 	else // sigma >= 0.5
-		q = (0.0561f*sigma + 0.5784f)*sigma - 0.2568f;
-	q2 = q*q;
-	sc = (1.1668 + q)*(3.203729649  + (2.21566 + q)*q);
+		q = (0.0561f * sigma + 0.5784f) * sigma - 0.2568f;
+	q2 = q * q;
+	sc = (1.1668 + q) * (3.203729649  + (2.21566 + q) * q);
 	// no gabor filtering here, so no complex multiplies, just the regular coefs.
 	// all negated here, so as not to have to recalc Triggs/Sdika matrix
-	cf[1] = q*(5.788961737 + (6.76492 + 3.0*q)*q)/ sc;
-	cf[2] = -q2*(3.38246 + 3.0*q)/sc;
+	cf[1] = q * (5.788961737 + (6.76492 + 3.0 * q) * q) / sc;
+	cf[2] = -q2 * (3.38246 + 3.0 * q) / sc;
 	// 0 & 3 unchanged
-	cf[3] = q2*q/sc;
+	cf[3] = q2 * q / sc;
 	cf[0] = 1.0 - cf[1] - cf[2] - cf[3];
 
 	// Triggs/Sdika border corrections,
@@ -336,7 +336,7 @@
 		// fast blur...
 		// bug #6656 part 1, probably when previous node_composite.c was split into separate files, it was not properly updated
 		// to include recent cvs commits (well, at least not defocus node), so this part was missing...
-		wt = aperture*128.f;
+		wt = minf(nqd->maxblur, aperture * 128.0f);
 		IIR_gauss_single(crad, wt);
 		IIR_gauss_single(wts, wt);
 		




More information about the Bf-blender-cvs mailing list