[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16238] branches/soc-2008-unclezeiv/source /blender: Minor changes:

Davide Vercelli davide.vercelli at gmail.com
Sat Aug 23 20:08:04 CEST 2008


Revision: 16238
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16238
Author:   unclezeiv
Date:     2008-08-23 20:08:04 +0200 (Sat, 23 Aug 2008)

Log Message:
-----------
Minor changes:
- the "dist" value for indirect lights is now globally selectable from the lightcuts panel
- allow more indirect light samples
- check for rendering interrupts (ESC button, re->test_break()) during pre-processing, as things can take pretty long when fiddling with the sliders
- default to "mid" color weighting
- added debug slider to select different debug printing options (when compiled with DEBUG_LIGHTCUTS)

Modified Paths:
--------------
    branches/soc-2008-unclezeiv/source/blender/blenloader/intern/readfile.c
    branches/soc-2008-unclezeiv/source/blender/makesdna/DNA_scene_types.h
    branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c
    branches/soc-2008-unclezeiv/source/blender/src/buttons_scene.c

Modified: branches/soc-2008-unclezeiv/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2008-unclezeiv/source/blender/blenloader/intern/readfile.c	2008-08-23 13:12:17 UTC (rev 16237)
+++ branches/soc-2008-unclezeiv/source/blender/blenloader/intern/readfile.c	2008-08-23 18:08:04 UTC (rev 16238)
@@ -7745,6 +7745,10 @@
 					r->lightcuts_env_map= 4096.0f;
 				if(r->lightcuts_area_lights<=0.0f)
 					r->lightcuts_area_lights= 4000.0f;
+				if(r->lightcuts_indir_dist<=0.0f)
+					r->lightcuts_indir_dist= 5.0f;
+				if(r->lightcuts_color_weight==0)
+					r->lightcuts_color_weight= 1;
 			}
 			
 			sce= sce->id.next;

Modified: branches/soc-2008-unclezeiv/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/soc-2008-unclezeiv/source/blender/makesdna/DNA_scene_types.h	2008-08-23 13:12:17 UTC (rev 16237)
+++ branches/soc-2008-unclezeiv/source/blender/makesdna/DNA_scene_types.h	2008-08-23 18:08:04 UTC (rev 16238)
@@ -321,6 +321,8 @@
 	float lightcuts_indir_fac;
 	short lightcuts_options;
 	short lightcuts_color_weight;
+	float lightcuts_indir_dist;
+	int lightcuts_debug_options;
 } RenderData;
 
 /* control render convert and shading engine */

Modified: branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c
===================================================================
--- branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c	2008-08-23 13:12:17 UTC (rev 16237)
+++ branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c	2008-08-23 18:08:04 UTC (rev 16238)
@@ -52,8 +52,14 @@
 #include "shading.h"
 
 /* #define LIGHTCUTS_DEBUG */
-/* #define LIGHTCUTS_DEBUG_INDIR */
 
+#define LC_DBG_TREE_BUILDTIMES   0x0001
+#define LC_DBG_TREE_PRINT        0x0002
+#define LC_DBG_INDIR_DISCARD_NAN 0x0004
+#define LC_DBG_INDIR_VPL_PRINT   0x0008
+#define LC_DBG_TRAV_A_NODE_PRINT 0x0010
+#define LC_DBG_TRAV_E_NODE_PRINT 0x0020
+
 /* = LA_X + 1 */
 #define CLUSTER_EMPTY 0
 #define CLUSTER_LOCAL 1
@@ -120,6 +126,7 @@
 	float sphere_dist;
 #ifdef LIGHTCUTS_DEBUG
 	int dbg_parent;
+	int dbg_options;
 #endif
 } LightcutsCluster;
 
@@ -177,6 +184,7 @@
 	float scene_diag;
 	float scene_min[3], scene_max[3];
 	float indir_fac;
+	float indir_dist;
 	int do_indir;
 	int options;
 	
@@ -184,6 +192,7 @@
 	double tree_creation_time;
 #ifdef LIGHTCUTS_DEBUG
 	int dbg_first_pixel;
+	int dbg_options;
 #endif
 } LightcutsData;
 
@@ -596,6 +605,7 @@
 #ifdef LIGHTCUTS_DEBUG
 	double p1, p2;
 	char timestr[256];
+	short print_times= (lcd->dbg_options & LC_DBG_TREE_BUILDTIMES);
 #endif
 
 	Heap * heap = BLI_heap_new();
@@ -605,7 +615,8 @@
 	KDTreeNearest *nearest= MEM_callocN(sizeof(KDTreeNearest) * tree->counter, "kdtreenearest");
 
 #ifdef LIGHTCUTS_DEBUG
-	p1= PIL_check_seconds_timer();
+	if (print_times)
+		p1= PIL_check_seconds_timer();
 #endif
 	
 	/* kdtree construction */
@@ -613,28 +624,34 @@
 		BLI_kdtree_insert(kdtree, i, array[i].lar->co, NULL);
 
 #ifdef LIGHTCUTS_DEBUG
-	p2 = PIL_check_seconds_timer();
-	BLI_timestr(p2 - p1, timestr);
-	printf("add nodes: %s\n", timestr);
-	p1=p2;
+	if (print_times) {		
+		p2 = PIL_check_seconds_timer();
+		BLI_timestr(p2 - p1, timestr);
+		printf("add nodes: %s\n", timestr);
+		p1=p2;
+	}
 #endif
 	
 	BLI_kdtree_balance(kdtree);
 
 #ifdef LIGHTCUTS_DEBUG
-	p2 = PIL_check_seconds_timer();
-	BLI_timestr(p2 - p1, timestr);
-	printf("balance: %s\n", timestr);
-	p1=p2;
+	if (print_times) {
+		p2 = PIL_check_seconds_timer();
+		BLI_timestr(p2 - p1, timestr);
+		printf("balance: %s\n", timestr);
+		p1=p2;
+	}
 #endif
 	
 	BLI_kdtree_build_correspondence(kdtree, 2);
 
 #ifdef LIGHTCUTS_DEBUG
-	p2 = PIL_check_seconds_timer();
-	BLI_timestr(p2 - p1, timestr);
-	printf("corr: %s\n", timestr);
-	p1=p2;
+	if (print_times) {
+		p2 = PIL_check_seconds_timer();
+		BLI_timestr(p2 - p1, timestr);
+		printf("corr: %s\n", timestr);
+		p1=p2;
+	}
 #endif
 		
 	for (i = 0; i < tree->counter; i++)
@@ -680,18 +697,22 @@
 	BLI_kdtree_free(kdtree);
 
 #ifdef LIGHTCUTS_DEBUG
-	p2 = PIL_check_seconds_timer();
-	BLI_timestr(p2 - p1, timestr);
-	printf("finally do stuff: %s\n", timestr);
-	p1=p2;
+	if (print_times) {
+		p2 = PIL_check_seconds_timer();
+		BLI_timestr(p2 - p1, timestr);
+		printf("finally do stuff: %s\n", timestr);
+		p1=p2;
+	}
 #endif
 
 	/* the last cluster added is the root of the tree */
 	tree->root = cluster_id;
 
 #ifdef LIGHTCUTS_DEBUG
-	dbg_check_tree(array, tree->root);
-	dbg_print_tree(array, tree->root, 0);
+	if (lcd->dbg_options & LC_DBG_TREE_PRINT) {
+		dbg_check_tree(array, tree->root);
+		dbg_print_tree(array, tree->root, 0);
+	}
 #endif
 	printf(" %d nodes used.\n", tree->root + 1);
 
@@ -867,6 +888,10 @@
 	dxyview[0]= dxyview[1]= 1.0f/(sqrtf((float)n));
 	
 	for (k= 0; k < n; k++) {
+		
+		if (k % 1000 == 0 && re->test_break())
+			break;
+		
 		/*
 		 * hammersley algorithm, from
 		 * Wong, Luk, Heng "Sampling with Hammersley and Halton Points"
@@ -1284,7 +1309,7 @@
 	}
 
 #ifdef LIGHTCUTS_DEBUG
-	if (fac >= 0.499f) {
+	if ((lcd->options & LC_DBG_INDIR_DISCARD_NAN) && fac >= 0.499f) {
 		lcd->stat_discard_nan++;
 		return;
 	}
@@ -1292,8 +1317,7 @@
 	
 	lar= (LampRen *)MEM_callocN(sizeof(LampRen), "lampren");
 	lamp_init(re, lar);
-	/* XXX: fixed distance or proportional to orig->dist? */
-	lar->dist= orig->dist / 2;
+	lar->dist= lcd->indir_dist;
 	lar->distkw= lar->dist * lar->dist;
 	lar->lay= orig->lay;
 	
@@ -1318,8 +1342,9 @@
 	lar->g= lar->energy * scol[1];
 	lar->b= lar->energy * scol[2];
 	
-#ifdef LIGHTCUTS_DEBUG_INDIR
-	printf("PYDBG %d: %f %f %f - %f %f %f - %f %f %f\n",
+#ifdef LIGHTCUTS_DEBUG
+	if (lcd->dbg_options & LC_DBG_INDIR_VPL_PRINT)
+		printf("PYDBG %d: %f %f %f - %f %f %f - %f %f %f\n",
 			lev, co[0], co[1], co[2], scol[0], scol[1], scol[2], isec.vec[0], isec.vec[1], isec.vec[2]);
 #endif
 	
@@ -1373,6 +1398,10 @@
 	}
 
 	for (k= 0, pos= 0; k < n; k++) {
+		
+		if (k % 1000 == 0 && re->test_break())
+			break;
+		
 		/*
 		 * hammersley algorithm, from
 		 * Wong, Luk, Heng "Sampling with Hammersley and Halton Points"
@@ -1464,10 +1493,14 @@
 	re->lcdata = lcd = MEM_callocN(sizeof(LightcutsData), "LightcutsData");
 	pointlights= &lcd->pointlights;
 	lcd->indir_fac= re->r.lightcuts_indir_fac;
+	lcd->indir_dist= re->r.lightcuts_indir_dist;
 	lcd->do_indir= re->r.lightcuts_indirect;
 	lcd->options= re->r.lightcuts_options;
 	lcd->error_rate= re->r.lightcuts_max_error;
 	lcd->scene_diag= RE_ray_tree_max_size(re->raytree);
+#ifdef LIGHTCUTS_DEBUG
+	lcd->dbg_options= re->r.lightcuts_debug_options;
+#endif
 	RE_ray_tree_aabb(re->raytree, lcd->scene_min, lcd->scene_max);
 	
 	if (lcd->options & LC_OPT_2ND_BOUNCE)
@@ -1516,6 +1549,9 @@
 		lar= go->lampren;
 		if(lar==NULL) continue;
 		
+		if (lcd->light_counter % 1000 == 0 && re->test_break())
+			break;
+		
 		if (lar->type == LA_AREA) {
 			convert_area_light(re, lcd, lar);
 			continue;
@@ -2014,7 +2050,7 @@
 					else {
 						used++;
 #ifdef LIGHTCUTS_DEBUG
-						if (lcd->dbg_first_pixel==0)
+						if (lcd->dbg_options & LC_DBG_TRAV_A_NODE_PRINT && lcd->dbg_first_pixel==0)
 							printf("A t:%d id:%4d eb:%7.5f fc:%7.5f\n",
 									j, root->id, root->error_bound, root->f_clus);
 #endif
@@ -2046,7 +2082,7 @@
 
 		hinode= &array[cn_hinode->id];
 #ifdef LIGHTCUTS_DEBUG
-		if (lcd->dbg_first_pixel==0) {
+		if (lcd->dbg_options & LC_DBG_TRAV_E_NODE_PRINT &&  lcd->dbg_first_pixel==0) {
 			printf("E t:%d id:%4d eb:%7.5f ebl:%7.5f cf:%7.5f fc:%7.5f (c1:%4d c2:%4d)\n",
 					CLUSTER_TYPE_TO_ARRAY_IDX(cn_hinode->type), cn_hinode->id,
 					cn_hinode->error_bound, cn_hinode->error_bound * hinode->luminance, cn_hinode->contr_factor, cn_hinode->f_clus,
@@ -2119,7 +2155,7 @@
 				else {
 					used++;
 #ifdef LIGHTCUTS_DEBUG
-					if (lcd->dbg_first_pixel==0)
+					if (lcd->dbg_options & LC_DBG_TRAV_A_NODE_PRINT && lcd->dbg_first_pixel==0)
 						printf("A t:%d id:%4d eb:%7.5f fc:%7.5f\n",
 								CLUSTER_TYPE_TO_ARRAY_IDX(cn_rep->type), cn_rep->id,
 								cn_rep->error_bound, cn_rep->f_clus);
@@ -2153,7 +2189,7 @@
 				else {
 					used++;
 #ifdef LIGHTCUTS_DEBUG
-					if (lcd->dbg_first_pixel==0)
+					if (lcd->dbg_options & LC_DBG_TRAV_A_NODE_PRINT && lcd->dbg_first_pixel==0)
 						printf("A t:%d id:%4d eb:%7.5f fc:%7.5f\n",
 								CLUSTER_TYPE_TO_ARRAY_IDX(cn_unrep->type), cn_unrep->id,
 								cn_unrep->error_bound, cn_unrep->f_clus);

Modified: branches/soc-2008-unclezeiv/source/blender/src/buttons_scene.c
===================================================================
--- branches/soc-2008-unclezeiv/source/blender/src/buttons_scene.c	2008-08-23 13:12:17 UTC (rev 16237)
+++ branches/soc-2008-unclezeiv/source/blender/src/buttons_scene.c	2008-08-23 18:08:04 UTC (rev 16238)
@@ -3441,25 +3441,37 @@
 	block= uiNewBlock(&curarea->uiblocks, "render_panel_lightcuts", UI_EMBOSS, UI_HELV, curarea->win);
 	if(uiNewPanel(curarea, block, "Lightcuts", "Render", 640, 0, 318, 204)==0) return;
 	
-	uiDefButBitI(block, TOG, R_LIGHTCUTS, B_DIFF, "Enable lightcuts", 692, 142, 192, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable lightcuts rendering");
-	uiDefButBitI(block, TOG, SCE_PASS_LCFAUX, B_SET_PASS, "False color", 692, 120, 192, 20, &srl->passflag, 0, 0, 0, 0, "(Debug option) Deliver false color pass");
+	uiBlockBeginAlign(block);
+	uiDefButBitI(block, TOG, R_LIGHTCUTS, B_DIFF, "Enable lightcuts", 0, 0, 192, 20, &G.scene->r.mode, 0, 0, 0, 0, "Enable lightcuts rendering");
+	uiDefButF(block, NUM, B_DIFF, "Max error:", 0, -22, 95, 20, &G.scene->r.lightcuts_max_error, 0.001, 1.0, 0, 0, "The maximum allowed error rate");
+	uiDefButI(block, NUM, B_DIFF, "Max cut:", 97, -22, 95, 20, &G.scene->r.lightcuts_max_cut, 0, 5000, 0, 0, "The maximum size of the cut (higher values increase rendering times for occluded areas)");
+	uiBlockEndAlign(block);
 	
-	uiDefButF(block, NUM, B_DIFF, "Max error:", 692, 98, 96, 20, &G.scene->r.lightcuts_max_error, 0.001, 1.0, 0, 0, "The maximum allowed error rate");
-	uiDefButI(block, NUM, B_DIFF, "Max cut:", 692+96, 98, 96, 20, &G.scene->r.lightcuts_max_cut, 0, 5000, 0, 0, "The maximum size of the cut (higher values increase rendering times for occluded areas)");
-	uiDefButI(block, NUM, B_DIFF, "Area lights:", 692, 76, 192, 20, &G.scene->r.lightcuts_area_lights, 0, 100000, 0, 0, "The number of point lights generated for all the area lights");

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list