Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-03-12 03:16:55 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-03-12 03:16:55 +0300
commit06a763f9d7a7ff337af94d93cca693b291d65be3 (patch)
tree2ba0af093e7df0231fc36357c05312d85eb1006c /source
parent92665b0a516f6f44602e7ab7af9a0f346ea2e9ec (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/render/intern/source/rayshade.c12
-rw-r--r--source/blender/render/intern/source/strand.c13
2 files changed, 18 insertions, 7 deletions
diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c
index c69507e6bf5..0acae258cf8 100644
--- a/source/blender/render/intern/source/rayshade.c
+++ b/source/blender/render/intern/source/rayshade.c
@@ -1824,7 +1824,7 @@ static float *threadsafe_table_sphere(int test, int thread, int xs, int ys, int
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 @@ static float *sphere_sampler(int type, int resol, int thread, int xs, int ys)
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,8 +2071,10 @@ static void ray_ao_spheresamp(ShadeInput *shi, float *ao, float *env)
envcolor= WO_AOPLAIN;
if(resol>32) resol= 32;
-
- vec= sphere_sampler(R.wrld.aomode, resol, shi->thread, shi->xs, shi->ys);
+
+ /* 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);
// warning: since we use full sphere now, and dotproduct is below, we do twice as much
tot= 2*resol*resol;
diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c
index 1591c7957c6..f7ec0050c5d 100644
--- a/source/blender/render/intern/source/strand.c
+++ b/source/blender/render/intern/source/strand.c
@@ -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_apply_shaderesult_alpha(ShadeResult *shr, float alpha)
}
}
-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 @@ void strand_shade_point(Render *re, ShadeSample *ssamp, StrandSegment *sseg, Str
/* 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 @@ static void strand_shade_get(Render *re, StrandShadeCache *cache, ShadeSample *s
/* 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];