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

Comparing ray/src/cv/bsdf2klems.c (file contents):
Revision 2.4 by greg, Thu Apr 25 03:12:08 2013 UTC vs.
Revision 2.10 by greg, Thu Sep 26 17:05:00 2013 UTC

# Line 25 | Line 25 | char                   *progname;
25   static const char       *kbasis = "LBNL/Klems Full";
26                                  /* number of BSDF samples per patch */
27   static int              npsamps = 256;
28 +                                /* limit on number of RBF lobes */
29 + static int              lobe_lim = 15000;
30  
31   /* Return angle basis corresponding to the given name */
32   ANGLE_BASIS *
# Line 174 | Line 176 | eval_bsdf(const char *fname)
176                      sum = 0;                    /* average over patches */
177                      for (n = npsamps; n-- > 0; ) {
178                          fo_getvec(vout, j+(n+frandom())/npsamps, abp);
179 <                        fi_getvec(vin, i+(n+frandom())/npsamps, abp);
179 >                        fi_getvec(vin, i+urand(n), abp);
180                          ec = SDevalBSDF(&sv, vout, vin, &bsd);
181                          if (ec != SDEnone)
182                                  goto err;
# Line 195 | Line 197 | eval_bsdf(const char *fname)
197                      sum = 0;                    /* average over patches */
198                      for (n = npsamps; n-- > 0; ) {
199                          bo_getvec(vout, j+(n+frandom())/npsamps, abp);
200 <                        bi_getvec(vin, i+(n+frandom())/npsamps, abp);
200 >                        bi_getvec(vin, i+urand(n), abp);
201                          ec = SDevalBSDF(&sv, vout, vin, &bsd);
202                          if (ec != SDEnone)
203                                  goto err;
# Line 216 | Line 218 | eval_bsdf(const char *fname)
218                      sum = 0;                    /* average over patches */
219                      for (n = npsamps; n-- > 0; ) {
220                          bo_getvec(vout, j+(n+frandom())/npsamps, abp);
221 <                        fi_getvec(vin, i+(n+frandom())/npsamps, abp);
221 >                        fi_getvec(vin, i+urand(n), abp);
222                          ec = SDevalBSDF(&sv, vout, vin, &bsd);
223                          if (ec != SDEnone)
224                                  goto err;
# Line 229 | Line 231 | eval_bsdf(const char *fname)
231              data_epilogue();
232          }
233                                                  /* back transmission */
234 <        if (bsd.tb != NULL) {
234 >        if ((bsd.tb != NULL) | (bsd.tf != NULL)) {
235              input_orient = -1; output_orient = 1;
236              data_prologue();
237              for (j = 0; j < abp->nangles; j++) {
238                  for (i = 0; i < abp->nangles; i++) {
239 <                    sum = 0;                    /* average over patches */
239 >                    sum = 0;            /* average over patches */
240                      for (n = npsamps; n-- > 0; ) {
241                          fo_getvec(vout, j+(n+frandom())/npsamps, abp);
242 <                        bi_getvec(vin, i+(n+frandom())/npsamps, abp);
242 >                        bi_getvec(vin, i+urand(n), abp);
243                          ec = SDevalBSDF(&sv, vout, vin, &bsd);
244                          if (ec != SDEnone)
245                                  goto err;
# Line 261 | Line 263 | static void
263   eval_function(char *funame)
264   {
265          ANGLE_BASIS     *abp = get_basis(kbasis);
266 +        int             assignD = (fundefined(funame) < 6);
267          double          iovec[6];
268          double          sum;
269          int             i, j, n;
# Line 281 | Line 284 | eval_function(char *funame)
284                      else
285                          bi_getvec(iovec, i+urand(n), abp);
286  
287 +                    if (assignD) {
288 +                        varset("Dx", '=', -iovec[3]);
289 +                        varset("Dy", '=', -iovec[4]);
290 +                        varset("Dz", '=', -iovec[5]);
291 +                        ++eclock;
292 +                    }
293                      sum += funvalue(funame, 6, iovec);
294                  }
295                  printf("\t%.3e\n", sum/npsamps);
# Line 312 | Line 321 | eval_rbf(void)
321              else
322                  bi_getvec(vin, i+.5*(i>0), abp);
323  
324 <            rbf = advect_rbf(vin);              /* compute radial basis func */
324 >            rbf = advect_rbf(vin, lobe_lim);    /* compute radial basis func */
325  
326              for (j = 0; j < abp->nangles; j++) {
327                  sum = 0;                        /* sample over exiting patch */
# Line 326 | Line 335 | eval_rbf(void)
335                  }
336                  bsdfarr[j*abp->nangles + i] = sum*output_orient/npsamps;
337              }
338 +            if (rbf != NULL)
339 +                free(rbf);
340          }
341          n = 0;                                  /* write out our matrix */
342          for (j = 0; j < abp->nangles; j++) {
# Line 376 | Line 387 | main(int argc, char *argv[])
387                  case 'q':
388                          kbasis = "LBNL/Klems Quarter";
389                          break;
390 +                case 'l':
391 +                        lobe_lim = atoi(argv[++i]);
392 +                        break;
393                  default:
394                          goto userr;
395                  }
# Line 384 | Line 398 | main(int argc, char *argv[])
398                          fprintf(stderr,
399          "%s: need single function with 6 arguments: bsdf(ix,iy,iz,ox,oy,oz)\n",
400                                          progname);
401 +                        fprintf(stderr, "\tor 3 arguments using Dx,Dy,Dz: bsdf(ix,iy,iz)\n",
402 +                                        progname);
403                          goto userr;
404                  }
405 +                ++eclock;
406                  xml_header(argc, argv);                 /* start XML output */
407                  xml_prologue(NULL);
408                  if (dofwd) {
# Line 444 | Line 461 | main(int argc, char *argv[])
461          return(0);
462   userr:
463          fprintf(stderr,
464 <        "Usage: %s [-n spp][-h|-q][bsdf.sir ..] > bsdf.xml\n", progname);
464 >        "Usage: %s [-n spp][-h|-q][-l maxlobes] [bsdf.sir ..] > bsdf.xml\n", progname);
465          fprintf(stderr,
466          "   or: %s [-n spp][-h|-q] bsdf_in.xml > bsdf_out.xml\n", progname);
467          fprintf(stderr,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines