diff --git a/intern/cycles/scene/light.cpp b/intern/cycles/scene/light.cpp index 11620c13b65..300210602d4 100644 --- a/intern/cycles/scene/light.cpp +++ b/intern/cycles/scene/light.cpp @@ -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(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; diff --git a/intern/cycles/scene/light.h b/intern/cycles/scene/light.h index ae7b6972a93..ef3cbfc97ef 100644 --- a/intern/cycles/scene/light.h +++ b/intern/cycles/scene/light.h @@ -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;