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

Comparing ray/src/cv/bsdfrep.c (file contents):
Revision 2.11 by greg, Thu Nov 22 06:07:17 2012 UTC vs.
Revision 2.14 by greg, Fri Sep 20 00:21:39 2013 UTC

# Line 26 | Line 26 | int                    single_plane_incident = -1;
26   int                     input_orient = 0;
27   int                     output_orient = 0;
28  
29 +                                /* BSDF histogram */
30 + int                     bsdf_hist[HISTLEN];
31 +
32 +                                /* BSDF value for boundary regions */
33 + double                  bsdf_min = 0;
34 +
35                                  /* processed incident DSF measurements */
36   RBFNODE                 *dsf_list = NULL;
37  
# Line 199 | Line 205 | rotate_rbf(RBFNODE *rbf, const FVECT invec)
205          VCOPY(rbf->invec, invec);
206   }
207  
202 /* Compute volume associated with Gaussian lobe */
203 double
204 rbf_volume(const RBFVAL *rbfp)
205 {
206        double  rad = R2ANG(rbfp->crad);
207
208        return((2.*M_PI) * rbfp->peak * rad*rad);
209 }
210
208   /* Compute outgoing vector from grid position */
209   void
210   ovec_from_pos(FVECT vec, int xpos, int ypos)
# Line 237 | Line 234 | pos_from_vec(int pos[2], const FVECT vec)
234          pos[1] = (int)(sq[1]*grid_res);
235   }
236  
237 + /* Compute volume associated with Gaussian lobe */
238 + double
239 + rbf_volume(const RBFVAL *rbfp)
240 + {
241 +        double  rad = R2ANG(rbfp->crad);
242 +        FVECT   odir;
243 +        double  elev, integ;
244 +                                /* infinite integral approximation */
245 +        integ = (2.*M_PI) * rbfp->peak * rad*rad;
246 +                                /* check if we're near horizon */
247 +        ovec_from_pos(odir, rbfp->gx, rbfp->gy);
248 +        elev = output_orient*odir[2];
249 +                                /* apply cut-off correction if > 1% */
250 +        if (elev < 2.8*rad) {
251 +                /* elev = asin(elev);   /* this is so crude, anyway... */
252 +                integ *= 1. - .5*exp(-.5*elev*elev/(rad*rad));
253 +        }
254 +        return(integ);
255 + }
256 +
257   /* Evaluate RBF for DSF at the given normalized outgoing direction */
258   double
259   eval_rbfrep(const RBFNODE *rp, const FVECT outvec)
260   {
261 +        double          minval = bsdf_min*output_orient*outvec[2];
262          double          res = 0;
263          const RBFVAL    *rbfp;
264          FVECT           odir;
265          double          sig2;
266          int             n;
267 <
268 <        if (rp == NULL)
267 >                                /* check for wrong side */
268 >        if (outvec[2] > 0 ^ output_orient > 0)
269                  return(.0);
270 +                                /* use minimum if no information avail. */
271 +        if (rp == NULL)
272 +                return(minval);
273 +                                /* sum radial basis function */
274          rbfp = rp->rbfa;
275          for (n = rp->nrbf; n--; rbfp++) {
276                  ovec_from_pos(odir, rbfp->gx, rbfp->gy);
# Line 257 | Line 279 | eval_rbfrep(const RBFNODE *rp, const FVECT outvec)
279                  if (sig2 > -19.)
280                          res += rbfp->peak * exp(sig2);
281          }
282 +        if (res < minval)       /* never return less than minval */
283 +                return(minval);
284          return(res);
285   }
286  
# Line 390 | Line 414 | save_bsdf_rep(FILE *ofp)
414          fprintf(ofp, "SYMMETRY=%d\n", !single_plane_incident * inp_coverage);
415          fprintf(ofp, "IO_SIDES= %d %d\n", input_orient, output_orient);
416          fprintf(ofp, "GRIDRES=%d\n", grid_res);
417 +        fprintf(ofp, "BSDFMIN=%g\n", bsdf_min);
418          fputformat(BSDFREP_FMT, ofp);
419          fputc('\n', ofp);
420                                          /* write each DSF */
# Line 453 | Line 478 | headline(char *s, void *p)
478          }
479          if (!strncmp(s, "GRIDRES=", 8)) {
480                  sscanf(s+8, "%d", &grid_res);
481 +                return(0);
482 +        }
483 +        if (!strncmp(s, "BSDFMIN=", 8)) {
484 +                sscanf(s+8, "%lf", &bsdf_min);
485                  return(0);
486          }
487          if (formatval(fmt, s) && strcmp(fmt, BSDFREP_FMT))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines