[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35480] trunk/blender/source/blender/ render/intern/source: Fix #25931: strand render + ray traced AO give tile image.

Brecht Van Lommel brechtvanlommel at pandora.be
Sat Mar 12 01:16:56 CET 2011


Revision: 35480
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35480
Author:   blendix
Date:     2011-03-12 00:16:55 +0000 (Sat, 12 Mar 2011)
Log Message:
-----------
Fix #25931: strand render + ray traced AO give tile image. The random numbers
for sampling were not consistent, now the RNG is seeded per strand, and some
tweaks were done to make the jittered sampler cache return consistent sample
numbers for strands.

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

Modified: trunk/blender/source/blender/render/intern/source/rayshade.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/rayshade.c	2011-03-11 23:27:15 UTC (rev 35479)
+++ trunk/blender/source/blender/render/intern/source/rayshade.c	2011-03-12 00:16:55 UTC (rev 35480)
@@ -1824,7 +1824,7 @@
 	return R.wrld.aotables+ thread*tot*3;
 }
 
-static float *sphere_sampler(int type, int resol, int thread, int xs, int ys)
+static float *sphere_sampler(int type, int resol, int thread, int xs, int ys, int reset)
 {
 	int tot;
 	float *vec;
@@ -1852,8 +1852,8 @@
 		float ang, *vec1;
 		int a;
 		
-		// returns table if xs and ys were equal to last call
-		sphere= threadsafe_table_sphere(1, thread, xs, ys, tot);
+		// returns table if xs and ys were equal to last call, and not resetting
+		sphere= (reset)? NULL: threadsafe_table_sphere(1, thread, xs, ys, tot);
 		if(sphere==NULL) {
 			sphere= threadsafe_table_sphere(0, thread, xs, ys, tot);
 			
@@ -2071,9 +2071,11 @@
 		envcolor= WO_AOPLAIN;
 	
 	if(resol>32) resol= 32;
+
+	/* get sphere samples. for faces we get the same samples for sample x/y values,
+	   for strand render we always require a new sampler because x/y are not set */
+	vec= sphere_sampler(R.wrld.aomode, resol, shi->thread, shi->xs, shi->ys, shi->strand != NULL);
 	
-	vec= sphere_sampler(R.wrld.aomode, resol, shi->thread, shi->xs, shi->ys);
-	
 	// warning: since we use full sphere now, and dotproduct is below, we do twice as much
 	tot= 2*resol*resol;
 

Modified: trunk/blender/source/blender/render/intern/source/strand.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/strand.c	2011-03-11 23:27:15 UTC (rev 35479)
+++ trunk/blender/source/blender/render/intern/source/strand.c	2011-03-12 00:16:55 UTC (rev 35480)
@@ -47,6 +47,7 @@
 #include "BLI_utildefines.h"
 #include "BLI_ghash.h"
 #include "BLI_memarena.h"
+#include "BLI_rand.h"
 
 #include "BKE_DerivedMesh.h"
 #include "BKE_key.h"
@@ -268,11 +269,12 @@
 	}
 }
 
-void strand_shade_point(Render *re, ShadeSample *ssamp, StrandSegment *sseg, StrandPoint *spoint)
+static void strand_shade_point(Render *re, ShadeSample *ssamp, StrandSegment *sseg, StrandVert *svert, StrandPoint *spoint)
 {
 	ShadeInput *shi= ssamp->shi;
 	ShadeResult *shr= ssamp->shr;
 	VlakRen vlr;
+	int seed;
 
 	memset(&vlr, 0, sizeof(vlr));
 	vlr.flag= R_SMOOTH;
@@ -290,6 +292,13 @@
 	/* cache for shadow */
 	shi->samplenr= re->shadowsamplenr[shi->thread]++;
 
+	/* all samples */
+	shi->mask= 0xFFFF;
+
+	/* seed RNG for consistent results across tiles */
+	seed = shi->strand->index + (svert - shi->strand->vert);
+	BLI_thread_srandom(shi->thread, seed);
+
 	shade_input_set_strand(shi, sseg->strand, spoint);
 	shade_input_set_strand_texco(shi, sseg->strand, sseg->v[1], spoint);
 	
@@ -352,7 +361,7 @@
 		/* not shaded yet, shade and insert into hash */
 		p.t= (sseg->v[1] == svert)? 0.0f: 1.0f;
 		strand_eval_point(sseg, &p);
-		strand_shade_point(re, ssamp, sseg, &p);
+		strand_shade_point(re, ssamp, sseg, svert, &p);
 
 		hashshr= MEM_callocN(sizeof(ShadeResult), "HashShadeResult");
 		*hashshr= ssamp->shr[0];




More information about the Bf-blender-cvs mailing list