Commit: a21d948fd7ec185a9678d902a11f90a58b6ec0f9
Author: Alaska
Date:   Thu Dec 8 11:54:28 2022 +0100
Branches: master
https://developer.blender.org/rBa21d948fd7ec185a9678d902a11f90a58b6ec0f9

Fix mesh light brightness when not using the light tree

The PDF of mesh lights were not being scaled by `pdf_selection` when
the light tree was disable. This resulted in the mesh lights having
the wrong PDF and thus the wrong brightness.

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

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

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

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

diff --git a/intern/cycles/kernel/light/distribution.h 
b/intern/cycles/kernel/light/distribution.h
index 45d6811d521..2f75a53ec2a 100644
--- a/intern/cycles/kernel/light/distribution.h
+++ b/intern/cycles/kernel/light/distribution.h
@@ -74,25 +74,26 @@ ccl_device_noinline bool 
light_distribution_sample(KernelGlobals kg,
     }
 
     const int shader_flag = kdistribution->mesh_light.shader_flag;
-    triangle_light_sample<in_volume_segment>(kg, prim, object, randu, randv, 
time, ls, P);
+    if (!triangle_light_sample<in_volume_segment>(kg, prim, object, randu, 
randv, time, ls, P)) {
+      return false;
+    }
     ls->shader |= shader_flag;
-    return (ls->pdf > 0.0f);
   }
+  else {
+    const int lamp = -prim - 1;
 
-  const int lamp = -prim - 1;
-
-  if (UNLIKELY(light_select_reached_max_bounces(kg, lamp, bounce))) {
-    return false;
-  }
+    if (UNLIKELY(light_select_reached_max_bounces(kg, lamp, bounce))) {
+      return false;
+    }
 
-  if (!light_sample<in_volume_segment>(kg, lamp, randu, randv, P, path_flag, 
ls)) {
-    return false;
+    if (!light_sample<in_volume_segment>(kg, lamp, randu, randv, P, path_flag, 
ls)) {
+      return false;
+    }
+    ls->pdf_selection = kernel_data.integrator.distribution_pdf_lights;
   }
 
-  ls->pdf_selection = kernel_data.integrator.distribution_pdf_lights;
   ls->pdf *= ls->pdf_selection;
-
-  return true;
+  return (ls->pdf > 0.0f);
 }
 
 ccl_device_inline float light_distribution_pdf_lamp(KernelGlobals kg)

_______________________________________________
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

Reply via email to