Commit: 3f1e3d2dfa61e784c978a1d7931c1bec8be1e9ff Author: Jeffrey Liu Date: Wed Jun 15 10:24:20 2022 -0400 Branches: soc-2022-many-lights-sampling https://developer.blender.org/rB3f1e3d2dfa61e784c978a1d7931c1bec8be1e9ff
Cycles: handle case where light tree importance is 0 =================================================================== 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 c5f1f52f05e..cf3ffa18497 100644 --- a/intern/cycles/kernel/light/light_tree.h +++ b/intern/cycles/kernel/light/light_tree.h @@ -154,8 +154,13 @@ ccl_device bool light_tree_sample(KernelGlobals kg, } } - /* Once we're at a leaf node, we can sample from the cluster of primitives inside. - * Right now, this is done by incrementing the CDF by the PDF. + /* Special case where there's only a single light. */ + if (knode->num_prims == 1) { + return light_sample<in_volume_segment>( + kg, -knode->child_index, randu, randv, P, path_flag, ls); + } + + /* Right now, sampling is done by incrementing the CDF by the PDF. * However, we first need to calculate the total importance so that we can normalize the CDF. */ float total_emitter_importance = 0.0f; for (int i = 0; i < knode->num_prims; i++) { @@ -163,12 +168,11 @@ ccl_device bool light_tree_sample(KernelGlobals kg, total_emitter_importance += light_tree_emitter_importance(kg, P, N, prim_index); } - /* to-do: need to handle a case when total importance is 0.*/ + /* to-do: need to handle a case when total importance is 0. */ if (total_emitter_importance == 0.0f) { - + return false; } - /* Once we have the total importance, we can normalize the CDF and sample it. */ const float inv_total_importance = 1 / total_emitter_importance; float emitter_cdf = 0.0f; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs