Cycles: initialize LCG for sss and hair sampling without using the sobol sampler,
slightly faster but also fixes the u/v sampling dimensions not longer being at even values which is needed for best results.
This commit is contained in:
@@ -258,8 +258,7 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
|
|||||||
difl = kernel_data.curve_kernel_data.minimum_width * len(pixdiff) * 0.5f;
|
difl = kernel_data.curve_kernel_data.minimum_width * len(pixdiff) * 0.5f;
|
||||||
}
|
}
|
||||||
float extmax = kernel_data.curve_kernel_data.maximum_width;
|
float extmax = kernel_data.curve_kernel_data.maximum_width;
|
||||||
float rng_hair_seed = path_rng(kg, rng, sample, rng_offset + PRNG_HAIR);
|
uint lcg_state = lcg_init(*rng + rng_offset + sample);
|
||||||
uint lcg_state = lcg_init(rng_hair_seed);
|
|
||||||
|
|
||||||
bool hit = scene_intersect(kg, &ray, visibility, &isect, &lcg_state, difl, extmax);
|
bool hit = scene_intersect(kg, &ray, visibility, &isect, &lcg_state, difl, extmax);
|
||||||
#else
|
#else
|
||||||
@@ -377,7 +376,7 @@ __device float4 kernel_path_progressive(KernelGlobals *kg, RNG *rng, int sample,
|
|||||||
|
|
||||||
/* do bssrdf scatter step if we picked a bssrdf closure */
|
/* do bssrdf scatter step if we picked a bssrdf closure */
|
||||||
if(sc) {
|
if(sc) {
|
||||||
uint lcg_state = lcg_init(rbsdf);
|
uint lcg_state = lcg_init(*rng + rng_offset + sample);
|
||||||
subsurface_scatter_step(kg, &sd, state.flag, sc, &lcg_state, false);
|
subsurface_scatter_step(kg, &sd, state.flag, sc, &lcg_state, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -601,7 +600,7 @@ __device void kernel_path_indirect(KernelGlobals *kg, RNG *rng, int sample, Ray
|
|||||||
|
|
||||||
/* do bssrdf scatter step if we picked a bssrdf closure */
|
/* do bssrdf scatter step if we picked a bssrdf closure */
|
||||||
if(sc) {
|
if(sc) {
|
||||||
uint lcg_state = lcg_init(rbsdf);
|
uint lcg_state = lcg_init(*rng + rng_offset + sample);
|
||||||
subsurface_scatter_step(kg, &sd, state.flag, sc, &lcg_state, false);
|
subsurface_scatter_step(kg, &sd, state.flag, sc, &lcg_state, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -930,8 +929,7 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
|
|||||||
difl = kernel_data.curve_kernel_data.minimum_width * len(pixdiff) * 0.5f;
|
difl = kernel_data.curve_kernel_data.minimum_width * len(pixdiff) * 0.5f;
|
||||||
}
|
}
|
||||||
float extmax = kernel_data.curve_kernel_data.maximum_width;
|
float extmax = kernel_data.curve_kernel_data.maximum_width;
|
||||||
float rng_hair_seed = path_rng(kg, rng, sample, rng_offset + PRNG_HAIR);
|
uint lcg_state = lcg_init(*rng + rng_offset + sample);
|
||||||
uint lcg_state = lcg_init(rng_hair_seed);
|
|
||||||
|
|
||||||
if(!scene_intersect(kg, &ray, visibility, &isect, &lcg_state, difl, extmax)) {
|
if(!scene_intersect(kg, &ray, visibility, &isect, &lcg_state, difl, extmax)) {
|
||||||
#else
|
#else
|
||||||
@@ -1017,7 +1015,7 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* set up random number generator */
|
/* set up random number generator */
|
||||||
uint lcg_state = lcg_init(rbsdf);
|
uint lcg_state = lcg_init(*rng + rng_offset + sample);
|
||||||
int num_samples = kernel_data.integrator.subsurface_samples;
|
int num_samples = kernel_data.integrator.subsurface_samples;
|
||||||
float num_samples_inv = 1.0f/num_samples;
|
float num_samples_inv = 1.0f/num_samples;
|
||||||
|
|
||||||
|
@@ -207,9 +207,9 @@ __device float lcg_step(uint *rng)
|
|||||||
return (float)*rng * (1.0f/(float)0xFFFFFFFF);
|
return (float)*rng * (1.0f/(float)0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
__device uint lcg_init(float seed)
|
__device uint lcg_init(uint seed)
|
||||||
{
|
{
|
||||||
uint rng = __float_as_int(seed);
|
uint rng = seed;
|
||||||
lcg_step(&rng);
|
lcg_step(&rng);
|
||||||
return rng;
|
return rng;
|
||||||
}
|
}
|
||||||
|
@@ -159,8 +159,7 @@ enum PathTraceDimension {
|
|||||||
PRNG_LIGHT_V = 5,
|
PRNG_LIGHT_V = 5,
|
||||||
PRNG_LIGHT_F = 6,
|
PRNG_LIGHT_F = 6,
|
||||||
PRNG_TERMINATE = 7,
|
PRNG_TERMINATE = 7,
|
||||||
PRNG_HAIR = 8,
|
PRNG_BOUNCE_NUM = 8
|
||||||
PRNG_BOUNCE_NUM = 9
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* these flags values correspond to raytypes in osl.cpp, so keep them in sync!
|
/* these flags values correspond to raytypes in osl.cpp, so keep them in sync!
|
||||||
|
Reference in New Issue
Block a user