Fix hiding receiver disabling light/shadow linking

Turns out it is not enough to check for the receiver/blocker set,
as the object might be hidden. This should not change the light
behavior.

Pull Request: https://projects.blender.org/blender/blender/pulls/108307
This commit is contained in:
Sergey Sharybin
2023-05-26 12:21:44 +02:00
committed by Sergey Sharybin
parent ef6439efb3
commit 5e971e8d7f
5 changed files with 62 additions and 2 deletions

View File

@@ -174,6 +174,24 @@ bool Light::has_contribution(Scene *scene)
return !is_zero(effective_shader->emission_estimate);
}
bool Light::has_light_linking() const
{
if (get_light_set_membership() != LIGHT_LINK_MASK_ALL) {
return true;
}
return false;
}
bool Light::has_shadow_linking() const
{
if (get_shadow_set_membership() != LIGHT_LINK_MASK_ALL) {
return true;
}
return false;
}
/* Light Manager */
LightManager::LightManager()

View File

@@ -82,6 +82,10 @@ class Light : public Node {
/* Check whether the light has contribution the scene. */
bool has_contribution(Scene *scene);
/* Check whether this light participates in light or shadow linking. */
bool has_light_linking() const;
bool has_shadow_linking() const;
friend class LightManager;
friend class LightTree;
};

View File

@@ -403,6 +403,32 @@ bool Object::usable_as_light() const
return false;
}
bool Object::has_light_linking() const
{
if (get_receiver_light_set()) {
return true;
}
if (get_light_set_membership() != LIGHT_LINK_MASK_ALL) {
return true;
}
return false;
}
bool Object::has_shadow_linking() const
{
if (get_blocker_shadow_set()) {
return true;
}
if (get_shadow_set_membership() != LIGHT_LINK_MASK_ALL) {
return true;
}
return false;
}
/* Object Manager */
ObjectManager::ObjectManager()

View File

@@ -113,6 +113,11 @@ class Object : public Node {
/* Check whether this object can be used as light-emissive. */
bool usable_as_light() const;
/* Check whether the object participates in light or shadow linking, either as a receiver/blocker
* or emitter. */
bool has_light_linking() const;
bool has_shadow_linking() const;
protected:
/* Specifies the position of the object in scene->objects and
* in the device vectors. Gets set in device_update. */

View File

@@ -491,10 +491,10 @@ void Scene::update_kernel_features()
else if (geom->is_pointcloud()) {
kernel_features |= KERNEL_FEATURE_POINTCLOUD;
}
if (object->get_receiver_light_set()) {
if (object->has_light_linking()) {
kernel_features |= KERNEL_FEATURE_LIGHT_LINKING;
}
if (object->get_blocker_shadow_set()) {
if (object->has_shadow_linking()) {
kernel_features |= KERNEL_FEATURE_SHADOW_LINKING;
}
}
@@ -503,6 +503,13 @@ void Scene::update_kernel_features()
if (light->get_use_caustics()) {
has_caustics_light = true;
}
if (light->has_light_linking()) {
kernel_features |= KERNEL_FEATURE_LIGHT_LINKING;
}
if (light->has_shadow_linking()) {
kernel_features |= KERNEL_FEATURE_SHADOW_LINKING;
}
}
dscene.data.integrator.use_caustics = false;