[Bf-blender-cvs] [35624cdfe51] soc-2020-production-ready-light-tree-2: Cycles: added comments to light tree code
Sam Kottler
noreply at git.blender.org
Thu Aug 20 16:43:27 CEST 2020
Commit: 35624cdfe5186ee916e4519a013ef5c078d9c667
Author: Sam Kottler
Date: Thu Aug 20 09:43:18 2020 -0500
Branches: soc-2020-production-ready-light-tree-2
https://developer.blender.org/rB35624cdfe5186ee916e4519a013ef5c078d9c667
Cycles: added comments to light tree code
===================================================================
M intern/cycles/kernel/kernel_light.h
M intern/cycles/kernel/kernel_path_surface.h
M intern/cycles/kernel/kernel_path_volume.h
===================================================================
diff --git a/intern/cycles/kernel/kernel_light.h b/intern/cycles/kernel/kernel_light.h
index 5b80e4f91e0..39b2a871d88 100644
--- a/intern/cycles/kernel/kernel_light.h
+++ b/intern/cycles/kernel/kernel_light.h
@@ -643,6 +643,10 @@ ccl_device_inline bool light_select_reached_max_bounces(KernelGlobals *kg, int i
return (bounce > kernel_tex_fetch(__lights, index).max_bounces);
}
+/*
+ * Finds the solid angle of the smallest cone with vertex P that contains the bounding box. If P is
+ * inside the bounding box light can be in any direction so use the entire sphere.
+ */
ccl_device float calc_bbox_solid_angle(float3 P,
float3 centroid_to_P_dir,
float3 bboxMin,
@@ -676,7 +680,10 @@ ccl_device float calc_bbox_solid_angle(float3 P,
}
}
-/* calculates the importance metric for the given node and shading point P */
+/* calculates the importance metric for the given node and shading point P
+ * If t_max is negative assume that V is the normal vector and use surface importance calculation.
+ * Otherwise assume that V is the ray direction and use volume importance.
+ */
ccl_device float calc_importance(KernelGlobals *kg,
float3 P,
float3 V,
@@ -717,20 +724,16 @@ ccl_device float calc_importance(KernelGlobals *kg,
const float cos_theta_prime = fast_cosf(theta_prime);
/* f_a|cos(theta'_i)| -- diffuse approximation */
- if (V != make_float3(0.0f, 0.0f, 0.0f)) {
- const float cos_theta_i = dot(V, -centroid_to_P_dir);
- const float theta_i = fast_acosf(cos_theta_i);
- const float theta_i_prime = fmaxf(theta_i - theta_u, 0.0f);
- const float cos_theta_i_prime = fast_cosf(theta_i_prime);
- const float abs_cos_theta_i_prime = fabsf(cos_theta_i_prime);
- /* doing something similar to bsdf_diffuse_eval_reflect() */
- /* TODO: Use theta_i or theta_i_prime here? */
- const float f_a = fmaxf(cos_theta_i_prime, 0.0f) * M_1_PI_F;
-
- return f_a * abs_cos_theta_i_prime * energy * cos_theta_prime / d2;
- }
-
- return energy * cos_theta_prime / d2;
+ const float cos_theta_i = dot(V, -centroid_to_P_dir);
+ const float theta_i = fast_acosf(cos_theta_i);
+ const float theta_i_prime = fmaxf(theta_i - theta_u, 0.0f);
+ const float cos_theta_i_prime = fast_cosf(theta_i_prime);
+ const float abs_cos_theta_i_prime = fabsf(cos_theta_i_prime);
+ /* doing something similar to bsdf_diffuse_eval_reflect() */
+ /* TODO: Use theta_i or theta_i_prime here? */
+ const float f_a = fmaxf(cos_theta_i_prime, 0.0f) * M_1_PI_F;
+
+ return f_a * abs_cos_theta_i_prime * energy * cos_theta_prime / d2;
}
else {
const float3 p_to_c = centroid - P;
diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h
index a061866e7fc..4a5a60c9a56 100644
--- a/intern/cycles/kernel/kernel_path_surface.h
+++ b/intern/cycles/kernel/kernel_path_surface.h
@@ -179,7 +179,6 @@ ccl_device void accum_light_tree_contribution(KernelGlobals *kg,
/* choose whether to go down both(split) or only one of the children */
if (can_split && split(kg, P, offset)) {
/* go down both child nodes */
- //++stack_idx;
randu_stack[stack_idx] = randu;
randv_stack[stack_idx] = randv;
offset_stack[stack_idx] = child_offsetL;
@@ -221,7 +220,6 @@ ccl_device void accum_light_tree_contribution(KernelGlobals *kg,
pdf_factor *= 1.0f - P_L;
}
- //++stack_idx;
can_split = false;
randu_stack[stack_idx] = randu;
randv_stack[stack_idx] = randv;
diff --git a/intern/cycles/kernel/kernel_path_volume.h b/intern/cycles/kernel/kernel_path_volume.h
index 7bff0828775..d4164f8f70a 100644
--- a/intern/cycles/kernel/kernel_path_volume.h
+++ b/intern/cycles/kernel/kernel_path_volume.h
@@ -290,7 +290,6 @@ ccl_device void accum_light_tree_contribution_volume(KernelGlobals *kg,
/* choose whether to go down both(split) or only one of the children */
if (can_split && split(kg, P, offset)) {
/* go down both child nodes */
- //++stack_idx;
randu_stack[stack_idx] = randu;
randv_stack[stack_idx] = randv;
offset_stack[stack_idx] = child_offsetL;
@@ -332,7 +331,6 @@ ccl_device void accum_light_tree_contribution_volume(KernelGlobals *kg,
pdf_factor *= 1.0f - P_L;
}
- //++stack_idx;
can_split = false;
randu_stack[stack_idx] = randu;
randv_stack[stack_idx] = randv;
More information about the Bf-blender-cvs
mailing list