From b645e7081d2bcc92108d4f6b3a97f84b20855650 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 27 Jul 2016 23:09:38 +0200 Subject: [PATCH] Fix T48790: Cycles render bug with zero strength lights. --- intern/cycles/render/light.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 9ef35820254..6a1437fefb9 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -443,9 +443,9 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen device->tex_alloc("__light_distribution", dscene->light_distribution); /* Portals */ - if(num_background_lights > 0 && light_index != scene->lights.size()) { + if(num_background_lights > 0 && light_index != num_lights) { kintegrator->portal_offset = light_index; - kintegrator->num_portals = scene->lights.size() - light_index; + kintegrator->num_portals = num_lights - light_index; kintegrator->portal_pdf = background_mis? 0.5f: 1.0f; } else { @@ -609,10 +609,20 @@ void LightManager::device_update_points(Device *device, Scene *scene) { int num_scene_lights = scene->lights.size(); - if(num_scene_lights == 0) + int num_lights = 0; + + foreach(Light *light, scene->lights) { + if(light->is_enabled) { + num_lights++; + } + } + + + float4 *light_data = dscene->light_data.resize(num_lights*LIGHT_SIZE); + + if(num_lights == 0) return; - float4 *light_data = dscene->light_data.resize(num_scene_lights*LIGHT_SIZE); int light_index = 0; foreach(Light *light, scene->lights) {