[Bf-blender-cvs] [5174bcb1f02] soc-2022-many-lights-sampling: Fix: light tree calculations fail for translucent materials
Jeffrey Liu
noreply at git.blender.org
Thu Jul 21 15:39:16 CEST 2022
Commit: 5174bcb1f029977ffb63c79b6dd2c595a187392f
Author: Jeffrey Liu
Date: Thu Jul 21 09:37:35 2022 -0400
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rB5174bcb1f029977ffb63c79b6dd2c595a187392f
Fix: light tree calculations fail for translucent materials
This reverts an optimization made for opaque surfaces, where we assign
zero importance to a light that's guaranteed to be behind a surface.
The issue is that this fails for translucent surfaces.
===================================================================
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 0de3cbf9d8b..4c39c97060e 100644
--- a/intern/cycles/kernel/light/light_tree.h
+++ b/intern/cycles/kernel/light/light_tree.h
@@ -48,8 +48,13 @@ ccl_device float light_tree_node_importance(const float3 P,
const float distance_squared = fmaxf(0.25f * len_squared(centroid - bbox_max),
len_squared(centroid - P));
+ /* to-do: should there be a different importance calculations for different surfaces?
+ * opaque surfaces could just return 0 importance in this case. */
const float theta = fast_acosf(dot(bcone_axis, -point_to_centroid));
- const float theta_i = fast_acosf(dot(point_to_centroid, N));
+ float theta_i = fast_acosf(dot(point_to_centroid, N));
+ if (theta_i > M_PI_2_F) {
+ theta_i = M_PI_F - theta_i;
+ }
const float theta_u = light_tree_bounding_box_angle(bbox_min, bbox_max, P, point_to_centroid);
/* to-do: compare this with directly using fmaxf and cosf. */
@@ -61,11 +66,7 @@ ccl_device float light_tree_node_importance(const float3 P,
const float cos_theta_prime = fast_cosf(theta_prime);
float cos_theta_i_prime = 1.0f;
- if (theta_i - theta_u > M_PI_2_F) {
- /* If the lights are guaranteed to be completely behind the shading point,
- * should we still perform further calculations? */
- return 0.0f;
- } else if (theta_i - theta_u > 0.0f) {
+ if (theta_i - theta_u > 0.0f) {
cos_theta_i_prime = fabsf(fast_cosf(theta_i - theta_u));
}
More information about the Bf-blender-cvs
mailing list