diff --git a/intern/cycles/blender/sync.cpp b/intern/cycles/blender/sync.cpp index ee008bc6dca..8defad43afd 100644 --- a/intern/cycles/blender/sync.cpp +++ b/intern/cycles/blender/sync.cpp @@ -349,8 +349,7 @@ void BlenderSync::sync_integrator(BL::ViewLayer &b_view_layer, bool background) bool use_light_tree = get_boolean(cscene, "use_light_tree"); integrator->set_use_light_tree(use_light_tree); - integrator->set_light_sampling_threshold( - (use_light_tree) ? 0.0f : get_float(cscene, "light_sampling_threshold")); + integrator->set_light_sampling_threshold(get_float(cscene, "light_sampling_threshold")); if (integrator->use_light_tree_is_modified()) { scene->light_manager->tag_update(scene, LightManager::UPDATE_ALL); diff --git a/intern/cycles/kernel/light/light.h b/intern/cycles/kernel/light/light.h index fe1df22bd60..5221845a79b 100644 --- a/intern/cycles/kernel/light/light.h +++ b/intern/cycles/kernel/light/light.h @@ -113,13 +113,16 @@ ccl_device_noinline bool light_sample(KernelGlobals kg, { int prim; MeshLight mesh_light; +#ifdef __LIGHT_TREE__ if (kernel_data.integrator.use_light_tree) { ccl_global const KernelLightTreeEmitter *kemitter = &kernel_data_fetch(light_tree_emitters, emitter_index); prim = kemitter->prim; mesh_light = kemitter->mesh_light; } - else { + else +#endif + { ccl_global const KernelLightDistribution *kdistribution = &kernel_data_fetch( light_distribution, emitter_index); prim = kdistribution->prim; diff --git a/intern/cycles/scene/integrator.cpp b/intern/cycles/scene/integrator.cpp index 7e5633733ae..8fdec524d66 100644 --- a/intern/cycles/scene/integrator.cpp +++ b/intern/cycles/scene/integrator.cpp @@ -255,8 +255,10 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene kintegrator->scrambling_distance = scrambling_distance; kintegrator->sobol_index_mask = reverse_integer_bits(next_power_of_two(aa_samples - 1) - 1); - kintegrator->use_light_tree = scene->integrator->use_light_tree; - if (light_sampling_threshold > 0.0f) { + /* NOTE: The kintegrator->use_light_tree is assigned to the efficient value in the light manager, + * and the synchronization code is expected to tag the light manager for update when the + * `use_light_tree` is changed. */ + if (light_sampling_threshold > 0.0f && !kintegrator->use_light_tree) { kintegrator->light_inv_rr_threshold = scene->film->get_exposure() / light_sampling_threshold; } else {