Cycles: initialize LCG for sss and hair sampling without using the sobol sampler,
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 17 Apr 2013 14:48:01 +0000 (14:48 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 17 Apr 2013 14:48:01 +0000 (14:48 +0000)
slightly faster but also fixes the u/v sampling dimensions not longer being at even
values which is needed for best results.

intern/cycles/kernel/kernel_path.h
intern/cycles/kernel/kernel_random.h
intern/cycles/kernel/kernel_types.h

index 5847b4831c4737d0f949954ae898e7137c7af8c3..30abf0c8eb6a2b1432648e9d1dab2eb171552804 100644 (file)
@@ -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;
 
index e2eb8d5db834de9cd6ce2dc1fca775b1f93538a2..fc33e226051e12a842685b1399a72dc096e8b062 100644 (file)
@@ -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;
 }
index 44c0f090c227c5cff7497210ed83c41d324e47ae..d07bd4dc1c8a277ed01023176de25418c6340bde 100644 (file)
@@ -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!