Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/kernel_random.h
| Show All 32 Lines | |||||
| /* Skip initial numbers that for some dimensions have clear patterns that | /* Skip initial numbers that for some dimensions have clear patterns that | ||||
| * don't cover the entire sample space. Ideally we would have a better | * don't cover the entire sample space. Ideally we would have a better | ||||
| * progressive pattern that doesn't suffer from this problem, because even | * progressive pattern that doesn't suffer from this problem, because even | ||||
| * with this offset some dimensions are quite poor. | * with this offset some dimensions are quite poor. | ||||
| */ | */ | ||||
| # define SOBOL_SKIP 64 | # define SOBOL_SKIP 64 | ||||
| ccl_device uint sobol_dimension(ccl_global const KernelGlobals *kg, int index, int dimension) | ccl_device uint sobol_dimension(KernelGlobals kg, int index, int dimension) | ||||
| { | { | ||||
| uint result = 0; | uint result = 0; | ||||
| uint i = index + SOBOL_SKIP; | uint i = index + SOBOL_SKIP; | ||||
| for (int j = 0, x; (x = find_first_set(i)); i >>= x) { | for (int j = 0, x; (x = find_first_set(i)); i >>= x) { | ||||
| j += x; | j += x; | ||||
| result ^= __float_as_uint(kernel_tex_fetch(__sample_pattern_lut, 32 * dimension + j - 1)); | result ^= __float_as_uint(kernel_tex_fetch(__sample_pattern_lut, 32 * dimension + j - 1)); | ||||
| } | } | ||||
| return result; | return result; | ||||
| } | } | ||||
| #endif /* __SOBOL__ */ | #endif /* __SOBOL__ */ | ||||
| ccl_device_forceinline float path_rng_1D(ccl_global const KernelGlobals *kg, | ccl_device_forceinline float path_rng_1D(KernelGlobals kg, | ||||
| uint rng_hash, | uint rng_hash, | ||||
| int sample, | int sample, | ||||
| int dimension) | int dimension) | ||||
| { | { | ||||
| #ifdef __DEBUG_CORRELATION__ | #ifdef __DEBUG_CORRELATION__ | ||||
| return (float)drand48(); | return (float)drand48(); | ||||
| #endif | #endif | ||||
| Show All 17 Lines | #ifdef __SOBOL__ | ||||
| */ | */ | ||||
| uint tmp_rng = cmj_hash_simple(dimension, rng_hash); | uint tmp_rng = cmj_hash_simple(dimension, rng_hash); | ||||
| shift = tmp_rng * (1.0f / (float)0xFFFFFFFF); | shift = tmp_rng * (1.0f / (float)0xFFFFFFFF); | ||||
| return r + shift - floorf(r + shift); | return r + shift - floorf(r + shift); | ||||
| #endif | #endif | ||||
| } | } | ||||
| ccl_device_forceinline void path_rng_2D(ccl_global const KernelGlobals *kg, | ccl_device_forceinline void path_rng_2D(KernelGlobals kg, | ||||
| uint rng_hash, | uint rng_hash, | ||||
| int sample, | int sample, | ||||
| int dimension, | int dimension, | ||||
| ccl_private float *fx, | ccl_private float *fx, | ||||
| ccl_private float *fy) | ccl_private float *fy) | ||||
| { | { | ||||
| #ifdef __DEBUG_CORRELATION__ | #ifdef __DEBUG_CORRELATION__ | ||||
| *fx = (float)drand48(); | *fx = (float)drand48(); | ||||
| Show All 39 Lines | |||||
| { | { | ||||
| const uint qx = 1103515245U * ((x >> 1U) ^ (y)); | const uint qx = 1103515245U * ((x >> 1U) ^ (y)); | ||||
| const uint qy = 1103515245U * ((y >> 1U) ^ (x)); | const uint qy = 1103515245U * ((y >> 1U) ^ (x)); | ||||
| const uint n = 1103515245U * ((qx) ^ (qy >> 3U)); | const uint n = 1103515245U * ((qx) ^ (qy >> 3U)); | ||||
| return n; | return n; | ||||
| } | } | ||||
| ccl_device_inline uint path_rng_hash_init(ccl_global const KernelGlobals *ccl_restrict kg, | ccl_device_inline uint path_rng_hash_init(KernelGlobals kg, | ||||
| const int sample, | const int sample, | ||||
| const int x, | const int x, | ||||
| const int y) | const int y) | ||||
| { | { | ||||
| const uint rng_hash = hash_iqnt2d(x, y) ^ kernel_data.integrator.seed; | const uint rng_hash = hash_iqnt2d(x, y) ^ kernel_data.integrator.seed; | ||||
| #ifdef __DEBUG_CORRELATION__ | #ifdef __DEBUG_CORRELATION__ | ||||
| srand48(rng_hash + sample); | srand48(rng_hash + sample); | ||||
| ▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines | |||||