diff --git a/intern/cycles/blender/geometry.cpp b/intern/cycles/blender/geometry.cpp index a576f8b1813..49b94ed8fe9 100644 --- a/intern/cycles/blender/geometry.cpp +++ b/intern/cycles/blender/geometry.cpp @@ -128,11 +128,6 @@ Geometry *BlenderSync::sync_geometry(BObjectInfo &b_ob_info, } if (!sync) { - /* Need to determine this every sync. */ - if (geom->is_light() && static_cast(geom)->get_is_portal()) { - world_use_portal = true; - } - /* If transform was applied to geometry, need full update. */ if (object_updated && geom->transform_applied) { ; diff --git a/intern/cycles/blender/light.cpp b/intern/cycles/blender/light.cpp index ead162e9f91..9acb3aeb99e 100644 --- a/intern/cycles/blender/light.cpp +++ b/intern/cycles/blender/light.cpp @@ -108,10 +108,6 @@ void BlenderSync::sync_light(BObjectInfo &b_ob_info, Light *light) light->set_is_portal(false); } - if (light->get_is_portal()) { - world_use_portal = true; - } - /* tag */ light->tag_update(scene); } @@ -173,9 +169,6 @@ void BlenderSync::sync_background_light(BL::SpaceView3D &b_v3d) light->set_use_mis(sample_as_light); light->set_max_bounces(get_int(cworld, "max_bounces")); - /* Force enable light again when world is resynced. */ - light->set_is_enabled(sample_as_light || world_use_portal); - /* Caustic light. */ light->set_use_caustics(get_boolean(cworld, "is_caustics_light")); diff --git a/intern/cycles/blender/object.cpp b/intern/cycles/blender/object.cpp index 033a6c0a93d..edad26b428c 100644 --- a/intern/cycles/blender/object.cpp +++ b/intern/cycles/blender/object.cpp @@ -538,8 +538,6 @@ void BlenderSync::sync_objects(BL::Depsgraph &b_depsgraph, geometry_motion_synced.clear(); } - world_use_portal = false; - if (!motion) { /* Object to geometry instance mapping is built for the reference time, as other * times just look up the corresponding geometry. */ diff --git a/intern/cycles/blender/sync.h b/intern/cycles/blender/sync.h index a9e18c8304b..75b99f6b615 100644 --- a/intern/cycles/blender/sync.h +++ b/intern/cycles/blender/sync.h @@ -237,7 +237,6 @@ class BlenderSync { set motion_times; void *world_map; bool world_recalc; - bool world_use_portal = false; BlenderViewportParameters viewport_parameters; Scene *scene; diff --git a/intern/cycles/scene/light.cpp b/intern/cycles/scene/light.cpp index 07499e009ee..7095ef5d5e7 100644 --- a/intern/cycles/scene/light.cpp +++ b/intern/cycles/scene/light.cpp @@ -157,7 +157,8 @@ bool Light::has_contribution(const Scene *scene, const Object *object) return false; } if (light_type == LIGHT_BACKGROUND) { - return is_enabled; + /* Will be determined after finishing processing all the lights. */ + return true; } if (light_type == LIGHT_AREA) { if ((get_sizeu() * get_sizev() * get_size() == 0.0f) || @@ -266,15 +267,12 @@ void LightManager::test_enabled_lights(Scene *scene) Light *light = static_cast(object->get_geometry()); light->is_enabled = light->has_contribution(scene, object); has_portal |= light->is_portal; - if (!light->is_enabled) { - continue; - } if (light->light_type == LIGHT_BACKGROUND) { background_lights.push_back(light); } - num_lights++; + num_lights += light->is_enabled; } LOG_INFO << "Total " << num_lights << " lights."; @@ -288,14 +286,16 @@ void LightManager::test_enabled_lights(Scene *scene) * - If we don't need it (no HDRs etc.) */ Shader *shader = scene->background->get_shader(scene); - const bool disable_mis = !(has_portal || shader->has_surface_spatial_varying); - if (disable_mis) { - LOG_INFO << "Background MIS has been disabled."; - } for (Light *light : background_lights) { - light->is_enabled = !disable_mis; - background_enabled = !disable_mis; - background_resolution = light->map_resolution; + light->is_enabled = has_portal || (light->use_mis && shader->has_surface_spatial_varying); + if (light->is_enabled) { + background_enabled = true; + background_resolution = light->map_resolution; + } + } + + if (!background_enabled) { + LOG_INFO << "Background MIS has been disabled."; } }