[Bf-blender-cvs] [5f105939257] soc-2022-many-lights-sampling: Cycles: limit light tree traversal to 8 splits
Jeffrey Liu
noreply at git.blender.org
Sun Sep 4 00:10:50 CEST 2022
Commit: 5f1059392575593169a57a0d193ac384a6a11782
Author: Jeffrey Liu
Date: Sat Sep 3 16:37:17 2022 -0500
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rB5f1059392575593169a57a0d193ac384a6a11782
Cycles: limit light tree traversal to 8 splits
===================================================================
M intern/cycles/kernel/light/light_tree.h
===================================================================
diff --git a/intern/cycles/kernel/light/light_tree.h b/intern/cycles/kernel/light/light_tree.h
index 55b0b43d1db..efe3a746b6d 100644
--- a/intern/cycles/kernel/light/light_tree.h
+++ b/intern/cycles/kernel/light/light_tree.h
@@ -287,6 +287,9 @@ ccl_device bool light_tree_sample(KernelGlobals kg,
stack[0] = 0;
pdfs[0] = 1.0f;
+ /* For now, we arbitrarily limit splitting to 8 so that it doesn't continuously split. */
+ int split_count = 0;
+
/* First traverse the light tree until a leaf node is reached.
* Also keep track of the probability of traversing to a given node,
* so that we can scale our PDF accordingly later. */
@@ -337,12 +340,14 @@ ccl_device bool light_tree_sample(KernelGlobals kg,
const int left_index = index + 1;
const int right_index = knode->child_index;
if (light_tree_should_split(kg, P, knode) &&
+ split_count < 8 &&
stack_index < stack_size - 1) {
stack[stack_index] = left_index;
pdfs[stack_index] = pdf;
stack[stack_index + 1] = right_index;
pdfs[stack_index + 1] = pdf;
stack_index++;
+ split_count++;
continue;
}
@@ -525,6 +530,8 @@ ccl_device float light_tree_pdf(KernelGlobals kg,
stack[0] = 0;
pdfs[0] = 1.0f;
+ int split_count = 0;
+
float light_tree_pdf = 0.0f;
float light_leaf_pdf = 0.0f;
float total_weight = 0.0f;
@@ -591,12 +598,15 @@ ccl_device float light_tree_pdf(KernelGlobals kg,
* We adaptively split if the variance is high enough. */
const int left_index = index + 1;
const int right_index = knode->child_index;
- if (light_tree_should_split(kg, P, knode) && stack_index < stack_size - 1) {
+ if (light_tree_should_split(kg, P, knode) &&
+ split_count < 8 &&
+ stack_index < stack_size - 1) {
stack[stack_index] = left_index;
pdfs[stack_index] = pdf;
stack[stack_index + 1] = right_index;
pdfs[stack_index + 1] = pdf;
stack_index++;
+ split_count++;
continue;
}
More information about the Bf-blender-cvs
mailing list