diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-17 18:48:01 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-17 18:48:01 +0400 |
commit | 45552a45950459e4bb83bc44d41eeaa5457bfdae (patch) | |
tree | 5b4784f2187eac1bea08e013d4f7b6bf449fb946 /intern/cycles/kernel | |
parent | cf0e457e524cfc9f496705de6cbf1e41c5118828 (diff) |
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.
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r-- | intern/cycles/kernel/kernel_path.h | 12 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_random.h | 4 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_types.h | 3 |
3 files changed, 8 insertions, 11 deletions
diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 5847b4831c4..30abf0c8eb6 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -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; } 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_hair_seed); + uint lcg_state = lcg_init(*rng + rng_offset + sample); bool hit = scene_intersect(kg, &ray, visibility, &isect, &lcg_state, difl, extmax); #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 */ 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); } } @@ -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 */ 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); } } @@ -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; } 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_hair_seed); + uint lcg_state = lcg_init(*rng + rng_offset + sample); if(!scene_intersect(kg, &ray, visibility, &isect, &lcg_state, difl, extmax)) { #else @@ -1017,7 +1015,7 @@ __device float4 kernel_path_non_progressive(KernelGlobals *kg, RNG *rng, int sam continue; /* 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; float num_samples_inv = 1.0f/num_samples; diff --git a/intern/cycles/kernel/kernel_random.h b/intern/cycles/kernel/kernel_random.h index e2eb8d5db83..fc33e226051 100644 --- a/intern/cycles/kernel/kernel_random.h +++ b/intern/cycles/kernel/kernel_random.h @@ -207,9 +207,9 @@ __device float lcg_step(uint *rng) 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); return rng; } diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 44c0f090c22..d07bd4dc1c8 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -159,8 +159,7 @@ enum PathTraceDimension { PRNG_LIGHT_V = 5, PRNG_LIGHT_F = 6, PRNG_TERMINATE = 7, - PRNG_HAIR = 8, - PRNG_BOUNCE_NUM = 9 + PRNG_BOUNCE_NUM = 8 }; /* these flags values correspond to raytypes in osl.cpp, so keep them in sync! |