[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13860] trunk/blender/source/blender/ render/intern/source/rayshade.c:

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Feb 25 11:58:13 CET 2008


Revision: 13860
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13860
Author:   blendix
Date:     2008-02-25 11:58:12 +0100 (Mon, 25 Feb 2008)

Log Message:
-----------

Fix for bug #8347: bug in raytraced shadow with edgesplit. Problem
was the new jittering of the start position gave self intersections,
especially noticable with for example edgesplit because in that case
it can't detect them as well. 'Solution' now is to bias the start
position away from the surface a bit according to how much the start
position was jittered.

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

Modified: trunk/blender/source/blender/render/intern/source/rayshade.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/rayshade.c	2008-02-25 04:53:37 UTC (rev 13859)
+++ trunk/blender/source/blender/render/intern/source/rayshade.c	2008-02-25 10:58:12 UTC (rev 13860)
@@ -1750,7 +1750,7 @@
 	QMCSampler *qsa=NULL;
 	QMCSampler *qsa_jit=NULL;
 	int samples=0;
-	float samp3d[3], jit[3];
+	float samp3d[3], jit[3], jitbias= 0.0f;
 
 	float fac=0.0f, vec[3];
 	float colsq[4];
@@ -1775,7 +1775,10 @@
 		if (do_soft) max_samples = lar->ray_totsamp;
 		else max_samples = (R.osa > 4)?R.osa:5;
 	}
-	
+
+	if(shi->vlr && ((shi->vlr->flag & R_FULL_OSA) == 0))
+		jitbias= 0.5f*(VecLength(shi->dxco) + VecLength(shi->dyco));
+
 	/* sampling init */
 	if (lar->ray_samp_method==LA_SAMP_HALTON) {
 		qsa = QMC_initSampler(SAMP_TYPE_HALTON, max_samples);
@@ -1805,6 +1808,11 @@
 			pos[0] += shi->dxco[0]*jit[0] + shi->dyco[0]*jit[1];
 			pos[1] += shi->dxco[1]*jit[0] + shi->dyco[1]*jit[1];
 			pos[2] += shi->dxco[2]*jit[0] + shi->dyco[2]*jit[1];
+			
+			/* bias away somewhat to avoid self intersection */
+			pos[0] -= jitbias*shi->vn[0];
+			pos[1] -= jitbias*shi->vn[1];
+			pos[2] -= jitbias*shi->vn[2];
 		}
 
 		if (do_soft) {





More information about the Bf-blender-cvs mailing list