Fix #136726: Cycles: Area light visible when size is 0
Area light with a size of zero should not contribute to the scene, so set the light as disabled. This does not only fix the reported bug where such light is visible to the camera, but also a regression in 4.2 where the light contributes to the scene when light tree is off. Pull Request: https://projects.blender.org/blender/blender/pulls/136763
This commit is contained in:
committed by
Weizhen Huang
parent
795a76029a
commit
c2ec66a75b
@@ -138,7 +138,7 @@ void Light::tag_update(Scene *scene)
|
||||
}
|
||||
}
|
||||
|
||||
bool Light::has_contribution(Scene *scene)
|
||||
bool Light::has_contribution(const Scene *scene, const Object *object)
|
||||
{
|
||||
if (strength == zero_float3()) {
|
||||
return false;
|
||||
@@ -149,6 +149,15 @@ bool Light::has_contribution(Scene *scene)
|
||||
if (light_type == LIGHT_BACKGROUND) {
|
||||
return true;
|
||||
}
|
||||
if (light_type == LIGHT_AREA) {
|
||||
if ((get_sizeu() * get_sizev() * get_size() == 0.0f) ||
|
||||
is_zero(transform_get_column(&object->get_tfm(), 0)) ||
|
||||
is_zero(transform_get_column(&object->get_tfm(), 1)))
|
||||
{
|
||||
/* Area light with a size of zero does not contribute to the scene. */
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const Shader *effective_shader = (get_shader()) ? get_shader() : scene->default_light;
|
||||
return !is_zero(effective_shader->emission_estimate);
|
||||
@@ -219,7 +228,7 @@ void LightManager::test_enabled_lights(Scene *scene)
|
||||
}
|
||||
|
||||
Light *light = static_cast<Light *>(object->get_geometry());
|
||||
light->is_enabled = light->has_contribution(scene);
|
||||
light->is_enabled = light->has_contribution(scene, object);
|
||||
has_portal |= light->is_portal;
|
||||
|
||||
if (light->light_type == LIGHT_BACKGROUND) {
|
||||
@@ -1297,7 +1306,7 @@ void LightManager::device_update_lights(DeviceScene *dscene, Scene *scene)
|
||||
if (light->ellipse) {
|
||||
area *= M_PI_4_F;
|
||||
}
|
||||
float invarea = (light->normalize && area != 0.0f) ? 1.0f / area : 1.0f;
|
||||
float invarea = light->normalize ? 1.0f / area : 1.0f;
|
||||
if (light->ellipse) {
|
||||
/* Negative inverse area indicates ellipse. */
|
||||
invarea = -invarea;
|
||||
|
||||
@@ -20,6 +20,7 @@ CCL_NAMESPACE_BEGIN
|
||||
|
||||
class Device;
|
||||
class DeviceScene;
|
||||
class Object;
|
||||
class Progress;
|
||||
class Scene;
|
||||
class Shader;
|
||||
@@ -64,7 +65,7 @@ class Light : public Geometry {
|
||||
void tag_update(Scene *scene);
|
||||
|
||||
/* Check whether the light has contribution the scene. */
|
||||
bool has_contribution(Scene *scene);
|
||||
bool has_contribution(const Scene *scene, const Object *object);
|
||||
|
||||
/* Shader */
|
||||
Shader *get_shader() const;
|
||||
|
||||
Reference in New Issue
Block a user