Cleanup: Cycles: Check if background light is enabled in one place.

`world_use_portal` is not needed anymore, now that we always add world
as object (b20b4218d5).
We now check if background light is enabled only in
`test_enabled_lights()`, depending on the sample settings.

Pull Request: https://projects.blender.org/blender/blender/pulls/144710
This commit is contained in:
Weizhen Huang
2025-08-19 12:19:43 +02:00
committed by Gitea
parent d866517708
commit c672aa9ef4
5 changed files with 12 additions and 27 deletions

View File

@@ -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<const Light *>(geom)->get_is_portal()) {
world_use_portal = true;
}
/* If transform was applied to geometry, need full update. */
if (object_updated && geom->transform_applied) {
;

View File

@@ -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"));

View File

@@ -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. */

View File

@@ -237,7 +237,6 @@ class BlenderSync {
set<float> motion_times;
void *world_map;
bool world_recalc;
bool world_use_portal = false;
BlenderViewportParameters viewport_parameters;
Scene *scene;

View File

@@ -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<Light *>(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.";
}
}