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.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user