[Bf-blender-cvs] [9260c0c] master: Cycles: Ignore light which has no contribution to the scene

Sergey Sharybin noreply at git.blender.org
Sat Jun 27 15:18:38 CEST 2015


Commit: 9260c0c2baf6ec8c03e10a895301fba0f9adfcb3
Author: Sergey Sharybin
Date:   Thu Jun 25 17:00:32 2015 +0200
Branches: master
https://developer.blender.org/rB9260c0c2baf6ec8c03e10a895301fba0f9adfcb3

Cycles: Ignore light which has no contribution to the scene

This commit makes it so light which has zero energy or doesn't has
emission shader at all is being ignored by the path tracing.

===================================================================

M	intern/cycles/render/light.cpp
M	intern/cycles/render/light.h

===================================================================

diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp
index 448bbc9..e1b81db 100644
--- a/intern/cycles/render/light.cpp
+++ b/intern/cycles/render/light.cpp
@@ -138,6 +138,14 @@ void Light::tag_update(Scene *scene)
 	scene->light_manager->need_update = true;
 }
 
+bool Light::has_contribution(Scene *scene)
+{
+	if(is_portal) {
+		return false;
+	}
+	return scene->shaders[shader]->has_surface_emission;
+}
+
 /* Light Manager */
 
 LightManager::LightManager()
@@ -162,7 +170,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
 	bool background_mis = false;
 
 	foreach(Light *light, scene->lights) {
-		if(!light->is_portal)
+		if(light->has_contribution(scene))
 			num_lights++;
 	}
 
@@ -301,7 +309,7 @@ void LightManager::device_update_distribution(Device *device, DeviceScene *dscen
 
 	int light_index = 0;
 	foreach(Light *light, scene->lights) {
-		if(light->is_portal)
+		if(!light->has_contribution(scene))
 			continue;
 
 		distribution[offset].x = totarea;
@@ -559,8 +567,9 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce
 	int light_index = 0;
 
 	foreach(Light *light, scene->lights) {
-		if(light->is_portal)
+		if(!light->has_contribution(scene)) {
 			continue;
+		}
 
 		float3 co = light->co;
 		int shader_id = scene->shader_manager->get_shader_id(light->shader);
@@ -720,7 +729,8 @@ void LightManager::device_update_points(Device *device, DeviceScene *dscene, Sce
 		light_index++;
 	}
 
-	assert(light_index == scene->lights.size());
+	VLOG(1) << "Number of lights without contribution: "
+	        << scene->lights.size() - light_index;
 
 	device->tex_alloc("__light_data", dscene->light_data);
 }
diff --git a/intern/cycles/render/light.h b/intern/cycles/render/light.h
index 824d99a..afec362 100644
--- a/intern/cycles/render/light.h
+++ b/intern/cycles/render/light.h
@@ -63,6 +63,9 @@ public:
 	int max_bounces;
 
 	void tag_update(Scene *scene);
+
+	/* Check whether the light has contribution the the scene. */
+	bool has_contribution(Scene *scene);
 };
 
 class LightManager {




More information about the Bf-blender-cvs mailing list