[Bf-blender-cvs] [f1a1c37fd70] soc-2022-many-lights-sampling: Use min importance in volumes

Alaska noreply at git.blender.org
Thu Nov 24 19:12:28 CET 2022


Commit: f1a1c37fd708567d5f4337d6993a485f3f1ca555
Author: Alaska
Date:   Thu Nov 24 19:12:18 2022 +0100
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rBf1a1c37fd708567d5f4337d6993a485f3f1ca555

Use min importance in volumes

Use both the max and min importance for deciding which branch
of the light tree to traverse down when in volumetric materials.

Here are some comparisons:
||Current soc-2022-many-lights-sampling|This patch|Not using the light tree|
|4 samples per pixel|{F13959168}|{F13959166}|{F13959170}|
|1024 samples per pixel|{F13959211}|{F13959213}|{F13959215}|

Reviewed By: brecht, weizhen

Differential Revision: https://developer.blender.org/D16575

===================================================================

M	intern/cycles/kernel/light/tree.h

===================================================================

diff --git a/intern/cycles/kernel/light/tree.h b/intern/cycles/kernel/light/tree.h
index f80935efd58..fff73a1392c 100644
--- a/intern/cycles/kernel/light/tree.h
+++ b/intern/cycles/kernel/light/tree.h
@@ -63,6 +63,7 @@ ccl_device void light_tree_cluster_importance(const float3 N_or_D,
   float cos_theta, cos_theta_i, sin_theta_i;
   /* cos(theta_i') in the paper, omitted for volume */
   float cos_min_incidence_angle = 1.0f;
+  float cos_max_incidence_angle = 1.0f;
   /* when sampling the light tree for the second time in `shade_volume.h` and when query the pdf in
    * `sample.h` */
   const bool in_volume = (dot(N_or_D, N_or_D) < 5e-4f);
@@ -97,6 +98,10 @@ ccl_device void light_tree_cluster_importance(const float3 N_or_D,
       cos_min_incidence_angle = cos_theta_i > cos_theta_u ?
                                     1.0f :
                                     cos_theta_i * cos_theta_u + sin_theta_i * sin_theta_u;
+
+      /* cos_max_incidence_angle = cos(min{theta_i + theta_u, pi}) */
+      cos_max_incidence_angle = fmaxf(cos_theta_i * cos_theta_u - sin_theta_i * sin_theta_u, 0.0f);
+
       /* If the node is guaranteed to be behind the surface we're sampling, and the surface is
        * opaque, then we can give the node an importance of 0 as it contributes nothing to the
        * surface. This is more accurate than the bbox test if we are calculating the importance of
@@ -142,16 +147,11 @@ ccl_device void light_tree_cluster_importance(const float3 N_or_D,
                          (in_volume_segment ? min_distance : sqr(min_distance)));
 
   /* TODO: also min importance for volume? */
-  if (in_volume_segment || in_volume) {
+  if (in_volume_segment) {
     min_importance = max_importance;
     return;
   }
 
-  /* compute mininum importance */
-  /* cos_max_incidence_angle = cos(min{theta_i + theta_u, pi}) */
-  const float cos_max_incidence_angle = fmaxf(
-      cos_theta_i * cos_theta_u - sin_theta_i * sin_theta_u, 0.0f);
-
   /* cos(theta + theta_o + theta_u) if theta + theta_o + theta_u < theta_e, 0 otherwise */
   float cos_max_outgoing_angle;
   const float cos_theta_plus_theta_u = cos_theta * cos_theta_u - sin_theta * sin_theta_u;



More information about the Bf-blender-cvs mailing list