Cycles: Fix correlation issues in certain cases
There were two cases where correlation issues were obvious: - File from T38710 was giving issues in 2.78a again - File from T50116 was having totally different shadow between sample 1 and sample 32. Use some more simplified version of CMJ hash which seems to give nice randomized value which solves the correlation. This commit will break all unit test files, but it's a bug fix so perhaps OK to commit this. This also fixes T41143: Sobol gives nonuniform noise Proper science paper about hash function is coming. Reviewers: brecht Reviewed By: brecht Subscribers: lukasstockner97 Differential Revision: https://developer.blender.org/D2385
This commit is contained in:
parent
87cd56b012
commit
9d50175b6c
Notes:
blender-bot
2023-02-14 10:18:55 +01:00
Referenced by commit d8661ee2d5
, Cycles: Remove re-hashing done in BPT volume code
Referenced by issue #41143, sobol gives nonuniform noise
|
@ -149,6 +149,15 @@ ccl_device_inline uint cmj_hash(uint i, uint p)
|
|||
return i;
|
||||
}
|
||||
|
||||
ccl_device_inline uint cmj_hash_simple(uint i, uint p)
|
||||
{
|
||||
i = (i ^ 61) ^ p;
|
||||
i += i << 3;
|
||||
i ^= i >> 4;
|
||||
i *= 0x27d4eb2d;
|
||||
return i;
|
||||
}
|
||||
|
||||
ccl_device_inline float cmj_randfloat(uint i, uint p)
|
||||
{
|
||||
return cmj_hash(i, p) * (1.0f / 4294967808.0f);
|
||||
|
|
|
@ -120,13 +120,11 @@ ccl_device_forceinline float path_rng_1D(KernelGlobals *kg, ccl_addr_space RNG *
|
|||
/* Cranly-Patterson rotation using rng seed */
|
||||
float shift;
|
||||
|
||||
/* using the same *rng value to offset seems to give correlation issues,
|
||||
* we could hash it with the dimension but this has a performance impact,
|
||||
* we need to find a solution for this */
|
||||
if(dimension & 1)
|
||||
shift = (*rng >> 16) * (1.0f/(float)0xFFFF);
|
||||
else
|
||||
shift = (*rng & 0xFFFF) * (1.0f/(float)0xFFFF);
|
||||
/* Hash rng with dimension to solve correlation issues.
|
||||
* See T38710, T50116.
|
||||
*/
|
||||
RNG tmp_rng = cmj_hash_simple(dimension, *rng);
|
||||
shift = tmp_rng * (1.0f/(float)0xFFFFFFFF);
|
||||
|
||||
return r + shift - floorf(r + shift);
|
||||
#endif
|
||||
|
|
|
@ -582,17 +582,12 @@ ccl_device VolumeIntegrateResult kernel_volume_integrate_heterogeneous_distance(
|
|||
ccl_device_noinline VolumeIntegrateResult kernel_volume_integrate(KernelGlobals *kg,
|
||||
PathState *state, ShaderData *sd, Ray *ray, PathRadiance *L, float3 *throughput, RNG *rng, bool heterogeneous)
|
||||
{
|
||||
/* workaround to fix correlation bug in T38710, can find better solution
|
||||
* in random number generator later, for now this is done here to not impact
|
||||
* performance of rendering without volumes */
|
||||
RNG tmp_rng = cmj_hash(*rng, state->rng_offset);
|
||||
|
||||
shader_setup_from_volume(kg, sd, ray);
|
||||
|
||||
if(heterogeneous)
|
||||
return kernel_volume_integrate_heterogeneous_distance(kg, state, ray, sd, L, throughput, &tmp_rng);
|
||||
return kernel_volume_integrate_heterogeneous_distance(kg, state, ray, sd, L, throughput, rng);
|
||||
else
|
||||
return kernel_volume_integrate_homogeneous(kg, state, ray, sd, L, throughput, &tmp_rng, true);
|
||||
return kernel_volume_integrate_homogeneous(kg, state, ray, sd, L, throughput, rng, true);
|
||||
}
|
||||
|
||||
/* Decoupled Volume Sampling
|
||||
|
|
Loading…
Reference in New Issue