ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cv/bsdfrbf.c
(Generate patch)

Comparing ray/src/cv/bsdfrbf.c (file contents):
Revision 2.2 by greg, Tue Nov 13 04:23:38 2012 UTC vs.
Revision 2.5 by greg, Fri Jun 28 23:18:51 2013 UTC

# Line 51 | Line 51 | add_bsdf_data(double theta_out, double phi_out, double
51          if (!isDSF)
52                  val *= ovec[2];         /* convert from BSDF to DSF */
53  
54 +                                        /* update BSDF histogram */
55 +        if (val < BSDF2BIG*ovec[2] && val > BSDF2SML*ovec[2])
56 +                ++bsdf_hist[histndx(val/ovec[2])];
57 +
58          pos_from_vec(pos, ovec);
59  
60          dsf_grid[pos[0]][pos[1]].vsum += val;
# Line 185 | Line 189 | cull_values(void)
189                  }
190   }
191  
192 + /* Compute minimum BSDF from histogram and clear it */
193 + static void
194 + comp_bsdf_min()
195 + {
196 +        int     cnt;
197 +        int     i, target;
198 +
199 +        cnt = 0;
200 +        for (i = HISTLEN; i--; )
201 +                cnt += bsdf_hist[i];
202 +        if (!cnt) {                             /* shouldn't happen */
203 +                bsdf_min = 0;
204 +                return;
205 +        }
206 +        target = cnt/100;                       /* ignore bottom 1% */
207 +        cnt = 0;
208 +        for (i = 0; cnt <= target; i++)
209 +                cnt += bsdf_hist[i];
210 +        bsdf_min = histval(i-1);
211 +        memset(bsdf_hist, 0, sizeof(bsdf_hist));
212 + }
213 +
214   /* Count up filled nodes and build RBF representation from current grid */
215   RBFNODE *
216   make_rbfrep(void)
# Line 203 | Line 229 | make_rbfrep(void)
229          for (i = 0; i < GRIDRES; i++)
230              for (j = 0; j < GRIDRES; j++)
231                  nn += dsf_grid[i][j].nval;
232 +                                /* compute minimum BSDF */
233 +        comp_bsdf_min();
234                                  /* allocate RBF array */
235          newnode = (RBFNODE *)malloc(sizeof(RBFNODE) + sizeof(RBFVAL)*(nn-1));
236          if (newnode == NULL)
# Line 260 | Line 288 | make_rbfrep(void)
288          nn = 0;                 /* compute sum for normalization */
289          while (nn < newnode->nrbf)
290                  newnode->vtotal += rbf_volume(&newnode->rbfa[nn++]);
291 <
291 > #ifdef DEBUG
292 >        fprintf(stderr, "Integrated DSF at (%.1f,%.1f) deg. is %.2f\n",
293 >                        get_theta180(newnode->invec), get_phi360(newnode->invec),
294 >                        newnode->vtotal);
295 > #endif
296          insert_dsf(newnode);
297  
298          return(newnode);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines