diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-06-25 18:00:32 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-06-27 16:13:08 +0300 |
commit | 9260c0c2baf6ec8c03e10a895301fba0f9adfcb3 (patch) | |
tree | 182b0b0e17f58f41d147925779c9d1ade0f53811 | |
parent | 48ef0501b7cbbd10d5462c68a2559b2b64848b97 (diff) |
Cycles: Ignore light which has no contribution to the scene
This commit makes it so light which has zero energy or doesn't has
emission shader at all is being ignored by the path tracing.
-rw-r--r-- | intern/cycles/render/light.cpp | 18 | ||||
-rw-r--r-- | intern/cycles/render/light.h | 3 |
2 files changed, 17 insertions, 4 deletions
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 448bbc9a608..e1b81db93ab 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -138,6 +138,14 @@ void Light::tag_update(Scene *scene) scene->light_manager->need_update = true; } +bool Light::has_contribution(Scene *scene) +{ + if(is_portal) { + return false; + } + return scene->shaders[shader]->has_surface_emission; +} + /* Light Manager */ LightManager::LightManager() @@ -162,7 +170,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen bool background_mis = false; foreach(Light *light, scene->lights) { - if(!light->is_portal) + if(light->has_contribution(scene)) num_lights++; } @@ -301,7 +309,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen int light_index = 0; foreach(Light *light, scene->lights) { - if(light->is_portal) + if(!light->has_contribution(scene)) continue; distribution[offset].x = totarea; @@ -559,8 +567,9 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce int light_index = 0; foreach(Light *light, scene->lights) { - if(light->is_portal) + if(!light->has_contribution(scene)) { continue; + } float3 co = light->co; int shader_id = scene->shader_manager->get_shader_id(light->shader); @@ -720,7 +729,8 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce light_index++; } - assert(light_index == scene->lights.size()); + VLOG(1) << "Number of lights without contribution: " + << scene->lights.size() - light_index; device->tex_alloc("__light_data", dscene->light_data); } diff --git a/intern/cycles/render/light.h b/intern/cycles/render/light.h index 824d99aeb93..afec3628dda 100644 --- a/intern/cycles/render/light.h +++ b/intern/cycles/render/light.h @@ -63,6 +63,9 @@ public: int max_bounces; void tag_update(Scene *scene); + + /* Check whether the light has contribution the the scene. */ + bool has_contribution(Scene *scene); }; class LightManager { |