[Bf-blender-cvs] [039eba79067] soc-2022-many-lights-sampling: Fix divisions by zero in adaptive splitting
Brecht Van Lommel
noreply at git.blender.org
Thu Oct 20 20:47:24 CEST 2022
Commit: 039eba7906758101d0e44a52e7efc13f84f65fc0
Author: Brecht Van Lommel
Date: Thu Oct 20 20:38:56 2022 +0200
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rB039eba7906758101d0e44a52e7efc13f84f65fc0
Fix divisions by zero in adaptive splitting
===================================================================
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 1d64d559c69..da5e4869c3b 100644
--- a/intern/cycles/kernel/light/light_tree.h
+++ b/intern/cycles/kernel/light/light_tree.h
@@ -216,7 +216,7 @@ ccl_device bool light_tree_should_split(KernelGlobals kg,
const float radius = len(bbox_max - centroid);
const float distance = len(P - centroid);
- if (distance < radius) {
+ if (distance <= radius) {
return true;
}
@@ -615,8 +615,6 @@ ccl_device float light_tree_pdf(KernelGlobals kg,
/* Leaf node */
if (knode->child_index <= 0) {
- float pdf_emitter_selection = 1.0f;
-
/* If the leaf node contains the target emitter, we are processing the last node.
* We then iterate through the lights to find the target emitter.
* Otherwise, we randomly select one. */
@@ -636,11 +634,18 @@ ccl_device float light_tree_pdf(KernelGlobals kg,
}
total_emitter_importance += light_importance;
}
- pdf_emitter_selection = target_emitter_importance / total_emitter_importance;
- const float pdf_reservoir = selected_reservoir_weight / total_reservoir_weight;
- pdf *= pdf_emitter_selection * pdf_reservoir;
+
+ if (total_emitter_importance > 0.0f) {
+ const float pdf_emitter_selection = target_emitter_importance / total_emitter_importance;
+ const float pdf_reservoir = selected_reservoir_weight / total_reservoir_weight;
+ pdf *= pdf_emitter_selection * pdf_reservoir;
+ }
+ else {
+ pdf = 0.0f;
+ }
}
else {
+ float pdf_emitter_selection = 1.0f;
selected_light = light_tree_cluster_select_emitter(
kg, &randu, P, N, has_transmission, knode, &pdf_emitter_selection);
More information about the Bf-blender-cvs
mailing list