Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/kernel/sample/pattern.h')
-rw-r--r--intern/cycles/kernel/sample/pattern.h37
1 files changed, 26 insertions, 11 deletions
diff --git a/intern/cycles/kernel/sample/pattern.h b/intern/cycles/kernel/sample/pattern.h
index 6477e29fa40..ebdecc1bff9 100644
--- a/intern/cycles/kernel/sample/pattern.h
+++ b/intern/cycles/kernel/sample/pattern.h
@@ -90,18 +90,33 @@ ccl_device_inline uint path_rng_hash_init(KernelGlobals kg,
return rng_hash;
}
-ccl_device_inline bool sample_is_even(int pattern, int sample)
+/**
+ * Splits samples into two different classes, A and B, which can be
+ * compared for variance estimation.
+ */
+ccl_device_inline bool sample_is_class_A(int pattern, int sample)
{
- if (pattern == SAMPLING_PATTERN_PMJ) {
- /* See Section 10.2.1, "Progressive Multi-Jittered Sample Sequences", Christensen et al.
- * We can use this to get divide sample sequence into two classes for easier variance
- * estimation. */
- return popcount(uint(sample) & 0xaaaaaaaa) & 1;
- }
- else {
- /* TODO(Stefan): Are there reliable ways of dividing Sobol-Burley into two classes? */
- return sample & 0x1;
+#if 0
+ if (!(pattern == SAMPLING_PATTERN_PMJ || pattern == SAMPLING_PATTERN_SOBOL_BURLEY)) {
+ /* Fallback: assign samples randomly.
+ * This is guaranteed to work "okay" for any sampler, but isn't good.
+ * (Note: the seed constant is just a random number to guard against
+ * possible interactions with other uses of the hash. There's nothing
+ * special about it.)
+ */
+ return hash_hp_seeded_uint(sample, 0xa771f873) & 1;
}
-}
+#else
+ (void)pattern;
+#endif
+ /* This follows the approach from section 10.2.1 of "Progressive
+ * Multi-Jittered Sample Sequences" by Christensen et al., but
+ * implemented with efficient bit-fiddling.
+ *
+ * This approach also turns out to work equally well with Sobol-Burley
+ * (see https://developer.blender.org/D15746#429471).
+ */
+ return popcount(uint(sample) & 0xaaaaaaaa) & 1;
+}
CCL_NAMESPACE_END