[Bf-blender-cvs] [0d76d746b8b] soc-2022-many-lights-sampling: Fix portal light, index was off due to light->is_enabled set to true for portal light

Weizhen Huang noreply at git.blender.org
Wed Nov 9 16:53:54 CET 2022


Commit: 0d76d746b8b6418ee6dd268fe88e066812286e55
Author: Weizhen Huang
Date:   Wed Nov 9 16:51:19 2022 +0100
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rB0d76d746b8b6418ee6dd268fe88e066812286e55

Fix portal light, index was off due to light->is_enabled set to true for
portal light

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

M	intern/cycles/scene/background.cpp
M	intern/cycles/scene/light.cpp

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

diff --git a/intern/cycles/scene/background.cpp b/intern/cycles/scene/background.cpp
index 0779313e5ba..d29a4c02423 100644
--- a/intern/cycles/scene/background.cpp
+++ b/intern/cycles/scene/background.cpp
@@ -104,19 +104,6 @@ void Background::device_update(Device *device, DeviceScene *dscene, Scene *scene
       kbackground->surface_shader |= SHADER_EXCLUDE_CAMERA;
   }
 
-  /* Find background index in lights. */
-  int device_light_index = 0;
-  int background_light_index = -1;
-  foreach (Light *light, scene->lights) {
-    if (light->get_is_enabled()) {
-      if (light->get_light_type() == LIGHT_BACKGROUND) {
-        background_light_index = device_light_index;
-      }
-      device_light_index++;
-    }
-  }
-  kbackground->light_index = background_light_index;
-
   /* Light group. */
   auto it = scene->lightgroups.find(lightgroup);
   if (it != scene->lightgroups.end()) {
diff --git a/intern/cycles/scene/light.cpp b/intern/cycles/scene/light.cpp
index 65d4c76fa8c..49a8e19c95a 100644
--- a/intern/cycles/scene/light.cpp
+++ b/intern/cycles/scene/light.cpp
@@ -811,8 +811,6 @@ void LightManager::device_update_background(Device *device,
 
   progress.set_status("Updating Lights", "Importance map");
 
-  assert(dscene->data.integrator.use_direct_light);
-
   int2 environment_res = make_int2(0, 0);
   Shader *shader = scene->background->get_shader(scene);
   int num_suns = 0;
@@ -856,6 +854,7 @@ void LightManager::device_update_background(Device *device,
         kbackground->sun = make_float4(
             sun_direction.x, sun_direction.y, sun_direction.z, half_angle);
 
+        /* empirical value */
         kbackground->sun_weight = 4.0f;
         environment_res.x = max(environment_res.x, 512);
         environment_res.y = max(environment_res.y, 256);
@@ -1040,6 +1039,8 @@ void LightManager::device_update_points(Device *, DeviceScene *dscene, Scene *sc
     else if (light->light_type == LIGHT_BACKGROUND) {
       uint visibility = scene->background->get_visibility();
 
+      dscene->data.background.light_index = light_index;
+
       shader_id &= ~SHADER_AREA_LIGHT;
       shader_id |= SHADER_USE_MIS;



More information about the Bf-blender-cvs mailing list