diff options
author | Thomas Dinges <blender@dingto.org> | 2016-02-06 00:13:51 +0300 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2016-02-06 00:13:51 +0300 |
commit | 469447f7077e42ec73d71e51f8f6bebc918fdfa6 (patch) | |
tree | f3c080413cc8e54c90b0c0650a46ccf16ccd1bc6 /intern/cycles/render/light.cpp | |
parent | ca88bc5ac13efd8ea7157ab97396db51bb0bda64 (diff) |
Cycles: Auto disable World MIS, if we only use a simple color.
When World MIS is enabled by the user, we now check if we actually need it.
In case of a simple node setup (no procedurals, no HDRs..) we auto disable MIS internally to save render time.
This change is important for upcoming default changes.
Diffstat (limited to 'intern/cycles/render/light.cpp')
-rw-r--r-- | intern/cycles/render/light.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 4e962616263..4212cc5fb5f 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -556,13 +556,28 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce if(scene->lights.size() == 0) return; - /* remove background light? */ - if(!(device->info.advanced_shading)) { - foreach(Light *light, scene->lights) { - if(light->type == LIGHT_BACKGROUND) { + /* Do we have a portal? */ + bool has_portal = false; + foreach(Light *light, scene->lights) { + if(light->is_portal) { + has_portal = true; + break; + } + } + + /* Remove background light: + * - If unsupported on a device + * - If we don't need it (no HDRs etc.) + */ + foreach(Light *light, scene->lights) { + if(light->type == LIGHT_BACKGROUND) { + Shader *shader = scene->shaders[scene->background->shader]; + bool auto_disable_mis = (!has_portal && !shader->has_surface_spatial_varying); + if(!(device->info.advanced_shading) || auto_disable_mis) { + VLOG(1) << "Background MIS has been disabled. \n"; scene->lights.erase(std::remove(scene->lights.begin(), scene->lights.end(), light), scene->lights.end()); - break; } + break; } } @@ -740,7 +755,7 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce void LightManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress) { - VLOG(1) << "Total " << scene->lights.size() << " lights."; + int lights_size = scene->lights.size(); if(!need_update) return; @@ -764,6 +779,11 @@ void LightManager::device_update(Device *device, DeviceScene *dscene, Scene *sce } need_update = false; + + if(lights_size != scene->lights.size()) + VLOG(1) << "Total " << scene->lights.size() << " lights (" << lights_size << " before optimization)."; + else + VLOG(1) << "Total " << scene->lights.size() << " lights."; } void LightManager::device_free(Device *device, DeviceScene *dscene) |