[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [16956] branches/soc-2008-unclezeiv/source /blender/render/intern/source/lightcuts.c: Improved the " multiple representative" option: rendering times should now be closer to those obtainable when the option is disabled .
Davide Vercelli
davide.vercelli at gmail.com
Tue Oct 7 02:10:17 CEST 2008
Revision: 16956
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16956
Author: unclezeiv
Date: 2008-10-07 02:10:17 +0200 (Tue, 07 Oct 2008)
Log Message:
-----------
Improved the "multiple representative" option: rendering times should now be closer to those obtainable when the option is disabled.
Modified Paths:
--------------
branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c
Modified: branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c
===================================================================
--- branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c 2008-10-06 22:39:06 UTC (rev 16955)
+++ branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c 2008-10-07 00:10:17 UTC (rev 16956)
@@ -156,6 +156,7 @@
short mrep_len;
short pad;
ClusRep *mrep_list;
+ float mrep_intensity;
#ifdef LIGHTCUTS_DEBUG
int dbg_parent;
int dbg_options;
@@ -179,6 +180,7 @@
float f_clus;
float f_clus_noshad;
float f_clus_spec;
+ LampRen *used_lar;
} CutNode;
typedef struct LightcutsTree {
@@ -395,18 +397,13 @@
if (lcd->options & LC_OPT_MULT_REPR) {
short found, used[LC_MAX_MULT_REPR * 2];
float x, lum;
- float tot_lum= 0.0f;
+ float tot_lum= one->mrep_intensity + two->mrep_intensity;
int i, j;
memset(used, 0, sizeof(used));
- /* calc tot_lum: TODO: slow but will change! */
- for (j= 0; j< one->mrep_len; j++)
- tot_lum+= one->mrep_list[j].intensity;
- for (j= 0; j< two->mrep_len; j++)
- tot_lum+= two->mrep_list[j].intensity;
-
dest->mrep_len= MAX2(one->mrep_len, two->mrep_len);
+ dest->mrep_intensity= 0.0f;
if (dest->mrep_len < LC_MAX_MULT_REPR) {
if (one->mrep_len == two->mrep_len)
@@ -432,6 +429,7 @@
if (x <= lum) {
dest->mrep_list[i].lar= one->mrep_list[j].lar;
dest->mrep_list[i].intensity= lum;
+ dest->mrep_intensity+= lum;
found= 1;
tot_lum-= lum;
used[j]= 1;
@@ -450,6 +448,7 @@
if (x <= lum) {
dest->mrep_list[i].lar= two->mrep_list[j].lar;
dest->mrep_list[i].intensity= lum;
+ dest->mrep_intensity+= lum;
found= 1;
tot_lum-= lum;
used[one->mrep_len + j]= 1;
@@ -656,7 +655,7 @@
clus->mrep_len= 1;
clus->mrep_list= MEM_callocN(sizeof(ClusRep), "clusrep");
clus->mrep_list[0].lar= clus->lar;
- clus->mrep_list[0].intensity= INPR(colw, clus->col);
+ clus->mrep_list[0].intensity= clus->mrep_intensity= INPR(colw, clus->col);
}
clus++;
@@ -2236,28 +2235,23 @@
dbg_convert[tree->node]= 0;
#endif
if (node->error_bound > FLT_EPSILON) {
- LampRen *lar= clus->lar;
float intensity= clus->intensity;
+ node->used_lar= clus->lar;
if (lcd->options & LC_OPT_MULT_REPR && clus->mrep_len > 1) {
int i;
- float rand, tot_lum= 0.0f;
- /* XXX */
- for (i= 0; i< clus->mrep_len; i++)
- tot_lum+= clus->mrep_list[i].intensity;
+ float rand= BLI_frand() * clus->mrep_intensity;
- rand= BLI_frand() * tot_lum;
-
for (i= 0; i< clus->mrep_len; i++) {
float lum= clus->mrep_list[i].intensity;
if (rand < lum) {
- lar= clus->mrep_list[i].lar;
+ node->used_lar= clus->mrep_list[i].lar;
intensity= clus->luminance / lum;
break;
}
rand -= lum;
}
}
- single_light_contrib(lar, si->shi, &i, &i_noshad, &t);
+ single_light_contrib(node->used_lar, si->shi, &i, &i_noshad, &t);
lcd->stat_rays_shot++;
node->contr_factor= MAX2(i, 0.0f);
node->contr_factor_spec= MAX2(t, 0.0f);
@@ -2283,7 +2277,7 @@
si->used++;
/* XXX unneeded for root ? */
- if (lar->lightcuts_options & LC_LAR_INDIRECT) {
+ if (node->used_lar->lightcuts_options & LC_LAR_INDIRECT) {
si->vpl_queue[si->vpl_to_cap]= node - si->cut_nodes;
si->vpl_to_cap++;
}
@@ -2441,7 +2435,15 @@
CutNode *cn_rep= &si.cut_nodes[si.free_node];
CutNode *cn_unrep= &si.cut_nodes[si.free_node + 1];
- if (hinode->lar != rep->lar)
+ if (lcd->options & LC_OPT_MULT_REPR) {
+ int i;
+ for (i= 0; i < rep->mrep_len; i++)
+ if (rep->mrep_list[i].lar == cn_hinode->used_lar)
+ break;
+ if (i == rep->mrep_len)
+ SWAP(LightcutsCluster*, rep, unrep);
+ }
+ else if (hinode->lar != rep->lar)
SWAP(LightcutsCluster*, rep, unrep);
#ifdef LIGHTCUTS_DEBUG
@@ -2467,9 +2469,9 @@
#endif
/* TODO: check if we can save some calculations with MR */
- if (lcd->options & LC_OPT_MULT_REPR)
- fill_cut_node(lcd, cn_rep, rep, &si);
- else
+ //if (lcd->options & LC_OPT_MULT_REPR)
+ // fill_cut_node(lcd, cn_rep, rep, &si);
+ //else
{
/* for the represented light we can reuse most calculations */
cn_rep->id= rep->id;
More information about the Bf-blender-cvs
mailing list