diff options
Diffstat (limited to 'intern/cycles/render')
-rw-r--r-- | intern/cycles/render/light.cpp | 32 | ||||
-rw-r--r-- | intern/cycles/render/osl.cpp | 25 | ||||
-rw-r--r-- | intern/cycles/render/shader.cpp | 1 | ||||
-rw-r--r-- | intern/cycles/render/shader.h | 1 | ||||
-rw-r--r-- | intern/cycles/render/svm.cpp | 7 |
5 files changed, 51 insertions, 15 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) diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp index 81c706ca1bc..67b07f1192e 100644 --- a/intern/cycles/render/osl.cpp +++ b/intern/cycles/render/osl.cpp @@ -570,14 +570,20 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath) /* test if we shader contains specific closures */ OSLShaderInfo *info = ((OSLShaderManager*)manager)->shader_loaded_info(name); - if(info && current_type == SHADER_TYPE_SURFACE) { - if(info->has_surface_emission) - current_shader->has_surface_emission = true; - if(info->has_surface_transparent) - current_shader->has_surface_transparent = true; - if(info->has_surface_bssrdf) { - current_shader->has_surface_bssrdf = true; - current_shader->has_bssrdf_bump = true; /* can't detect yet */ + if(current_type == SHADER_TYPE_SURFACE) { + if(info) { + if(info->has_surface_emission) + current_shader->has_surface_emission = true; + if(info->has_surface_transparent) + current_shader->has_surface_transparent = true; + if(info->has_surface_bssrdf) { + current_shader->has_surface_bssrdf = true; + current_shader->has_bssrdf_bump = true; /* can't detect yet */ + } + } + + if(node->has_spatial_varying()) { + current_shader->has_surface_spatial_varying = true; } } else if(current_type == SHADER_TYPE_VOLUME) { @@ -752,6 +758,8 @@ void OSLCompiler::generate_nodes(const ShaderNodeSet& nodes) current_shader->has_surface_emission = true; if(node->has_surface_transparent()) current_shader->has_surface_transparent = true; + if(node->has_spatial_varying()) + current_shader->has_surface_spatial_varying = true; if(node->has_surface_bssrdf()) { current_shader->has_surface_bssrdf = true; if(node->has_bssrdf_bump()) @@ -839,6 +847,7 @@ void OSLCompiler::compile(Scene *scene, OSLGlobals *og, Shader *shader) shader->has_bssrdf_bump = false; shader->has_volume = false; shader->has_displacement = false; + shader->has_surface_spatial_varying = false; shader->has_volume_spatial_varying = false; shader->has_object_dependency = false; shader->has_integrator_dependency = false; diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index 6852d3f0608..0b3509fa1b1 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -152,6 +152,7 @@ Shader::Shader() has_volume = false; has_displacement = false; has_bssrdf_bump = false; + has_surface_spatial_varying = false; has_volume_spatial_varying = false; has_object_dependency = false; has_integrator_dependency = false; diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h index 5b8c53110eb..cc83ad03277 100644 --- a/intern/cycles/render/shader.h +++ b/intern/cycles/render/shader.h @@ -106,6 +106,7 @@ public: bool has_displacement; bool has_surface_bssrdf; bool has_bssrdf_bump; + bool has_surface_spatial_varying; bool has_volume_spatial_varying; bool has_object_dependency; bool has_integrator_dependency; diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp index d715419530b..f3d39c1bd72 100644 --- a/intern/cycles/render/svm.cpp +++ b/intern/cycles/render/svm.cpp @@ -397,7 +397,11 @@ void SVMCompiler::generate_node(ShaderNode *node, ShaderNodeSet& done) stack_clear_users(node, done); stack_clear_temporary(node); - if(current_type == SHADER_TYPE_VOLUME) { + if(current_type == SHADER_TYPE_SURFACE) { + if(node->has_spatial_varying()) + current_shader->has_surface_spatial_varying = true; + } + else if(current_type == SHADER_TYPE_VOLUME) { if(node->has_spatial_varying()) current_shader->has_volume_spatial_varying = true; } @@ -761,6 +765,7 @@ void SVMCompiler::compile(Scene *scene, shader->has_bssrdf_bump = false; shader->has_volume = false; shader->has_displacement = false; + shader->has_surface_spatial_varying = false; shader->has_volume_spatial_varying = false; shader->has_object_dependency = false; shader->has_integrator_dependency = false; |