[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16088] branches/soc-2008-unclezeiv/source /blender/render/intern/source/lightcuts.c: Improved Oren Nayar bounding: the bounding was previously way too loose and would result in very slow renderings , as the algorithm would never reach a satisfying error level.

Davide Vercelli davide.vercelli at gmail.com
Thu Aug 14 00:00:50 CEST 2008


Revision: 16088
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16088
Author:   unclezeiv
Date:     2008-08-14 00:00:49 +0200 (Thu, 14 Aug 2008)

Log Message:
-----------
Improved Oren Nayar bounding: the bounding was previously way too loose and would result in very slow renderings, as the algorithm would never reach a satisfying error level.

Modified Paths:
--------------
    branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c

Modified: branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c
===================================================================
--- branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c	2008-08-13 21:13:56 UTC (rev 16087)
+++ branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c	2008-08-13 22:00:49 UTC (rev 16088)
@@ -1397,7 +1397,7 @@
 {
 	float nv, t, A, B;
 	float View_B[3], lmin[3], lmax[3], mat[3][3];
-	float bound_sin_tan, x;
+	float bound_sin_tan, k1, k2;
 	
 	if(max_dot <= 0.0f)
 		return 0.0f;
@@ -1428,14 +1428,16 @@
 	 *     a = MAX(acos(realnl), acos(nv)), b = MIN(*)
 	 *     sin(a) * tan(b)
 	 * this is equivalent to:
-	 *     a = MAX(realnl, nv), b = MIN(*)
+	 *     a = MIN(realnl, nv), b = MAX(*)
 	 *     sqrt(1 - a * a) * sqrt(1 - b * b) / b
 	 * which in turn is bound by:
-	 *     sqrt(1 - b * b) * sqrt(1 - b * b) / b = (1 - b * b) / b
+	 *     sqrt(1 - a * a) * sqrt(1 - a * a) / b = (1 - a * a) / b
 	 * Tighter bounds could possibly be found.
 	 */
-	x = MIN3(nv, min_dot, 0.95);
-	bound_sin_tan= 1 / x - x;
+	k1= MIN3(nv, min_dot, 0.95);
+	k2= MAX2(nv, max_dot);
+	k2= MIN2(k2, 0.95);
+	bound_sin_tan= (1 - k1*k1) / k2;
 	
 	/* TODO: optim: these values can be precomputed (also in shadeoutput.c) */
 	A = 1.0f - 0.5f * rough_sq / (rough_sq + 0.33f);





More information about the Bf-blender-cvs mailing list