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.25 by greg, Thu Aug 21 10:33:48 2014 UTC vs.
Revision 2.28 by greg, Thu May 28 15:46:28 2015 UTC

# Line 34 | Line 34 | unsigned long          bsdf_hist[HISTLEN];
34  
35                                  /* BSDF value for boundary regions */
36   double                  bsdf_min = 0;
37 < float                   bsdf_spec_peak = 0;
38 < int                     bsdf_spec_crad = 0;
37 > double                  bsdf_spec_peak = 0;
38 > double                  bsdf_spec_rad = 0;
39  
40                                  /* processed incident DSF measurements */
41   RBFNODE                 *dsf_list = NULL;
# Line 50 | Line 50 | double                 theta_in_deg, phi_in_deg;
50   int
51   new_input_direction(double new_theta, double new_phi)
52   {
53        if (!input_orient)              /* check input orientation */
54                input_orient = 1 - 2*(new_theta > 90.);
55        else if (input_orient > 0 ^ new_theta < 90.) {
56                fprintf(stderr,
57                "%s: Cannot handle input angles on both sides of surface\n",
58                                progname);
59                return(0);
60        }
53                                          /* normalize angle ranges */
54          while (new_theta < -180.)
55                  new_theta += 360.;
# Line 67 | Line 59 | new_input_direction(double new_theta, double new_phi)
59                  new_theta = -new_theta;
60                  new_phi += 180.;
61          }
70        if ((theta_in_deg = new_theta) < 1.0)
71                return(1);              /* don't rely on phi near normal */
62          while (new_phi < 0)
63                  new_phi += 360.;
64          while (new_phi >= 360.)
65                  new_phi -= 360.;
66 +                                        /* check input orientation */
67 +        if (!input_orient)
68 +                input_orient = 1 - 2*(new_theta > 90.);
69 +        else if (input_orient > 0 ^ new_theta < 90.) {
70 +                fprintf(stderr,
71 +                "%s: Cannot handle input angles on both sides of surface\n",
72 +                                progname);
73 +                return(0);
74 +        }
75 +        if ((theta_in_deg = new_theta) < 1.0)
76 +                return(1);              /* don't rely on phi near normal */
77          if (single_plane_incident > 0)  /* check input coverage */
78                  single_plane_incident = (round(new_phi) == round(phi_in_deg));
79          else if (single_plane_incident < 0)
# Line 290 | Line 291 | eval_rbfrep(const RBFNODE *rp, const FVECT outvec)
291                  ovec_from_pos(odir, rbfp->gx, rbfp->gy);
292                  res += rbfp->peak * exp((DOT(odir,outvec) - 1.) / rad2);
293          }
294 <        res /= output_orient*outvec[2];
294 >        res /= COSF(outvec[2]);
295          if (res < bsdf_min)     /* never return less than bsdf_min */
296                  return(bsdf_min);
297          return(res);
# Line 406 | Line 407 | def_rbf_spec(const FVECT invec)
407  
408          if (input_orient > 0 ^ invec[2] > 0)    /* wrong side? */
409                  return(NULL);
410 <        if ((bsdf_spec_peak <= bsdf_min) | (bsdf_spec_crad <= 0))
410 >        if ((bsdf_spec_peak <= bsdf_min) | (bsdf_spec_rad <= 0))
411                  return(NULL);                   /* nothing set */
412          rbf = (RBFNODE *)malloc(sizeof(RBFNODE));
413          if (rbf == NULL)
# Line 421 | Line 422 | def_rbf_spec(const FVECT invec)
422          VCOPY(rbf->invec, invec);
423          rbf->nrbf = 1;
424          rbf->rbfa[0].peak = bsdf_spec_peak * output_orient*ovec[2];
425 <        rbf->rbfa[0].crad = bsdf_spec_crad;
425 >        rbf->rbfa[0].crad = ANG2R(bsdf_spec_rad);
426          rbf->rbfa[0].gx = pos[0];
427          rbf->rbfa[0].gy = pos[1];
428          rbf->vtotal = rbf_volume(rbf->rbfa);
# Line 536 | Line 537 | clear_bsdf_rep(void)
537          grid_res = GRIDRES;
538          bsdf_min = 0;
539          bsdf_spec_peak = 0;
540 <        bsdf_spec_crad = 0;
540 >        bsdf_spec_rad = 0;
541   }
542  
543   /* Write our BSDF mesh interpolant out to the given binary stream */
# Line 555 | Line 556 | save_bsdf_rep(FILE *ofp)
556          fprintf(ofp, "IO_SIDES= %d %d\n", input_orient, output_orient);
557          fprintf(ofp, "GRIDRES=%d\n", grid_res);
558          fprintf(ofp, "BSDFMIN=%g\n", bsdf_min);
559 <        if ((bsdf_spec_peak > bsdf_min) & (bsdf_spec_crad > 0))
560 <                fprintf(ofp, "BSDFSPEC= %f %f\n", bsdf_spec_peak,
560 <                                        R2ANG(bsdf_spec_crad));
559 >        if ((bsdf_spec_peak > bsdf_min) & (bsdf_spec_rad > 0))
560 >                fprintf(ofp, "BSDFSPEC= %f %f\n", bsdf_spec_peak, bsdf_spec_rad);
561          fputformat(BSDFREP_FMT, ofp);
562          fputc('\n', ofp);
563                                          /* write each DSF */
# Line 636 | Line 636 | headline(char *s, void *p)
636                  return(0);
637          }
638          if (!strncmp(s, "BSDFSPEC=", 9)) {
639 <                float   bsdf_spec_rad = 0;
640 <                sscanf(s+9, "%f %f", &bsdf_spec_peak, &bsdf_spec_rad);
641 <                bsdf_spec_crad = ANG2R(bsdf_spec_rad);
639 >                sscanf(s+9, "%lf %lf", &bsdf_spec_peak, &bsdf_spec_rad);
640                  return(0);
641          }
642          if (formatval(fmt, s) && strcmp(fmt, BSDFREP_FMT))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines