Revision: 15192
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15192
Author: unclezeiv
Date: 2008-06-11 00:29:50 +0200 (Wed, 11 Jun 2008)
Log Message:
-----------
Cut nodes are now sorted according to total subtree luminance, instead of the
currently misnomed "intensity" value.
Minor changes:
- renamed cut nodes variables
- added more debug code
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-06-10 21:15:48 UTC (rev 15191)
+++ branches/soc-2008-unclezeiv/source/blender/render/intern/source/lightcuts.c
2008-06-10 22:29:50 UTC (rev 15192)
@@ -542,6 +542,8 @@
#ifdef LIGHTCUTS_DEBUG
int dbg_convert[lcd->max_lights * 2]; /* from cluster id to index in
cut_nodes */
+
+ float dbg_totlum = 0.0f;
#endif
cut_nodes= lcd->cut_nodes + shi->thread * lcd->cut_nodes_size;
@@ -566,44 +568,47 @@
root->f_clus_noshad= i_noshad * clus->intensity;
VECADDFAC(totest_noshad, totest_noshad, clus->col,
root->f_clus_noshad);
}
+#ifdef LIGHTCUTS_DEBUG
+ dbg_totlum= root->contr_factor * clus->luminance;
+#endif
- BLI_heap_insert(cut, -root->error_bound * clus->intensity,
root);
+ BLI_heap_insert(cut, -root->error_bound * clus->luminance,
root);
}
/* at each iteration the heap grows by one, but we have a maximum size
*/
while (BLI_heap_size(cut) < (lcd->max_lights - used) &&
BLI_heap_size(cut) > 0) {
- LightcutsCluster *c_hinode;
- CutNode *hinode;
+ LightcutsCluster *hinode;
+ CutNode *cn_hinode;
it++;
- hinode= BLI_heap_popmin(cut);
- if (hinode < cut_nodes || hinode >= (cut_nodes +
lcd->cut_nodes_size)) {
+ cn_hinode= BLI_heap_popmin(cut);
+ if (cn_hinode < cut_nodes || cn_hinode >= (cut_nodes +
lcd->cut_nodes_size)) {
printf("tricky node! at %d, %d (it=%d)\n", shi->xs,
shi->ys, it);
break;
}
- if (hinode->error_bound < hinode->contr_factor) {
+ if (cn_hinode->error_bound < cn_hinode->contr_factor) {
printf("troublesome node! at %d, %d (it=%d): eb %7.5f <
cf %7.5f\n",
- shi->xs, shi->ys, it, hinode->error_bound,
hinode->contr_factor);
+ shi->xs, shi->ys, it, cn_hinode->error_bound,
cn_hinode->contr_factor);
break;
}
- c_hinode= &lcd->array_local[hinode->id];
+ hinode= &lcd->array_local[cn_hinode->id];
- if (c_hinode->child1==0 && c_hinode->child2==0) {
+ if (hinode->child1==0 && hinode->child2==0) {
/* can't go further down */
used++;
continue;
}
- if (LC_LUMINOSITY(totest) * lcd->error_rate >
hinode->error_bound * c_hinode->intensity) {
+ if (LC_LUMINOSITY(totest) * lcd->error_rate >
cn_hinode->error_bound * hinode->luminance) {
break;
} else {
- LightcutsCluster *rep=
&lcd->array_local[c_hinode->child1];
- LightcutsCluster *unrep=
&lcd->array_local[c_hinode->child2];
- CutNode *c_rep= &cut_nodes[free_node];
- CutNode *c_unrep= &cut_nodes[free_node + 1];
+ LightcutsCluster *rep=
&lcd->array_local[hinode->child1];
+ LightcutsCluster *unrep=
&lcd->array_local[hinode->child2];
+ CutNode *cn_rep= &cut_nodes[free_node];
+ CutNode *cn_unrep= &cut_nodes[free_node + 1];
- if (c_hinode->lar != rep->lar)
+ if (hinode->lar != rep->lar)
SWAP(LightcutsCluster*, rep, unrep);
#ifdef LIGHTCUTS_DEBUG
@@ -618,41 +623,50 @@
* but please note that it's the same quantity
* we are not calculating it in different ways
*/
- VECADDFAC(totest, totest, rep->col, -hinode->f_clus);
+ VECADDFAC(totest, totest, hinode->col,
-cn_hinode->f_clus);
+#ifdef LIGHTCUTS_DEBUG
+ dbg_totlum-= cn_hinode->contr_factor *
hinode->luminance;
+#endif
/* this is a strong assumption on linearity of
intensity contribution... is it strong indeed?
* and numerically questionable again */
/* TODO: there is room to reuse the same block here */
/* for the reprsented light we can reuse most
calculations */
- c_rep->id= rep->id;
- c_rep->error_bound= calc_geometric_eb(lcd, rep->id,
shi->co);
- c_rep->contr_factor= hinode->contr_factor;
- c_rep->f_clus= hinode->contr_factor * rep->intensity;
- VECADDFAC(totest, totest, rep->col, c_rep->f_clus);
+ cn_rep->id= rep->id;
+ cn_rep->error_bound= calc_geometric_eb(lcd, rep->id,
shi->co);
+ cn_rep->contr_factor= cn_hinode->contr_factor;
+ cn_rep->f_clus= cn_hinode->contr_factor *
rep->intensity;
+ VECADDFAC(totest, totest, rep->col, cn_rep->f_clus);
+#ifdef LIGHTCUTS_DEBUG
+ dbg_totlum+= rep->luminance * cn_rep->contr_factor;
+#endif
- BLI_heap_insert(cut, -c_rep->error_bound *
rep->intensity, c_rep);
+ BLI_heap_insert(cut, -cn_rep->error_bound *
rep->luminance, cn_rep);
/* for the "unrepresented" light we have to compute
stuff from scratch */
- c_unrep->id= unrep->id;
- c_unrep->error_bound= calc_geometric_eb(lcd, unrep->id,
shi->co);
+ cn_unrep->id= unrep->id;
+ cn_unrep->error_bound= calc_geometric_eb(lcd,
unrep->id, shi->co);
get_contrib(unrep->lar, shi, &i, &i_noshad);
- c_unrep->contr_factor= i;
- c_unrep->f_clus= i * unrep->intensity;
- VECADDFAC(totest, totest, unrep->col, c_unrep->f_clus);
+ cn_unrep->contr_factor= i;
+ cn_unrep->f_clus= i * unrep->intensity;
+ VECADDFAC(totest, totest, unrep->col, cn_unrep->f_clus);
+#ifdef LIGHTCUTS_DEBUG
+ dbg_totlum+= unrep->luminance * cn_unrep->contr_factor;
+#endif
+
+ BLI_heap_insert(cut, -cn_unrep->error_bound *
unrep->luminance, cn_unrep);
- BLI_heap_insert(cut, -c_unrep->error_bound *
unrep->intensity, c_unrep);
-
if(shi->passflag & (SCE_PASS_DIFFUSE|SCE_PASS_SHADOW)) {
- VECADDFAC(totest_noshad, totest_noshad,
rep->col, -hinode->f_clus_noshad);
+ VECADDFAC(totest_noshad, totest_noshad,
rep->col, -cn_hinode->f_clus_noshad);
- c_rep->contr_factor_noshad=
hinode->contr_factor_noshad;
- c_rep->f_clus_noshad=
hinode->contr_factor_noshad * rep->intensity;
- VECADDFAC(totest_noshad, totest_noshad,
rep->col, c_rep->f_clus_noshad);
+ cn_rep->contr_factor_noshad=
cn_hinode->contr_factor_noshad;
+ cn_rep->f_clus_noshad=
cn_hinode->contr_factor_noshad * rep->intensity;
+ VECADDFAC(totest_noshad, totest_noshad,
rep->col, cn_rep->f_clus_noshad);
- c_unrep->contr_factor_noshad= i_noshad;
- c_unrep->f_clus_noshad= i_noshad *
unrep->intensity;
- VECADDFAC(totest_noshad, totest_noshad,
unrep->col, c_unrep->f_clus_noshad);
+ cn_unrep->contr_factor_noshad= i_noshad;
+ cn_unrep->f_clus_noshad= i_noshad *
unrep->intensity;
+ VECADDFAC(totest_noshad, totest_noshad,
unrep->col, cn_unrep->f_clus_noshad);
}
}
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs