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

Comparing ray/src/cv/bsdf2rad.c (file contents):
Revision 2.5 by greg, Tue Nov 26 17:33:55 2013 UTC vs.
Revision 2.10 by greg, Sun Mar 30 17:23:28 2014 UTC

# Line 22 | Line 22 | const float    colarr[6][3] = {
22                  .5, 1., 1.
23          };
24  
25 + char    validf[] = "-e \"valid(s,t)=X`SYS(s,t)^2+Y`SYS(s,t)^2+Z`SYS(s,t)^2-1e-7\"";
26 +
27   char    *progname;
28  
29   /* Produce a Radiance model plotting the indicated incident direction(s) */
# Line 91 | Line 93 | main(int argc, char *argv[])
93   #ifdef DEBUG
94          fprintf(stderr, "Minimum BSDF set to %.4f\n", bsdf_min);
95   #endif
96 <        min_log = log(bsdf_min*.5);
96 >        min_log = log(bsdf_min*.5 + 1e-5);
97                                                  /* output BSDF rep. */
98          for (n = 0; (n < 6) & (2*n+3 < argc); n++) {
99 <                double  theta = atof(argv[2*n+2]);
99 >                double  theta = (M_PI/180.)*atof(argv[2*n+2]);
100 >                double  phi = (M_PI/180.)*atof(argv[2*n+3]);
101 >                if (theta < -FTINY) {
102 >                        fprintf(stderr, "%s: theta values must be positive\n",
103 >                                        progname);
104 >                        return(1);
105 >                }
106                  if (inpXML) {
107 <                        input_orient = (theta <= 90.) ? 1 : -1;
107 >                        input_orient = (theta <= M_PI/2.) ? 1 : -1;
108                          output_orient = doTrans ? -input_orient : input_orient;
109                  }
110 <                idir[2] = sin((M_PI/180.)*theta);
111 <                idir[0] = idir[2] * cos((M_PI/180.)*atof(argv[2*n+3]));
112 <                idir[1] = idir[2] * sin((M_PI/180.)*atof(argv[2*n+3]));
110 >                idir[2] = sin(theta);
111 >                idir[0] = idir[2] * cos(phi);
112 >                idir[1] = idir[2] * sin(phi);
113                  idir[2] = input_orient * sqrt(1. - idir[2]*idir[2]);
114   #ifdef DEBUG
115                  fprintf(stderr, "Computing BSDF for incident direction (%.1f,%.1f)\n",
# Line 131 | Line 139 | main(int argc, char *argv[])
139                          for (i = 0; i < rbf->nrbf; i++) {
140                                  ovec_from_pos(odir, rbf->rbfa[i].gx, rbf->rbfa[i].gy);
141                                  bsdf = eval_rbfrep(rbf, odir) / (output_orient*odir[2]);
142 <                                bsdf = log(bsdf) - min_log;
142 >                                bsdf = log(bsdf + 1e-5) - min_log;
143                                  printf("pmat sphere p%d\n0\n0\n4 %f %f %f %f\n",
144                                          i+1, odir[0]*bsdf, odir[1]*bsdf, odir[2]*bsdf,
145                                                  .007*bsdf);
146                          }
147                  }
148                  fflush(stdout);
149 <                sprintf(buf, "gensurf tmat bsdf - - - %d %d", GRIDRES-1, GRIDRES-1);
149 >                sprintf(buf, "gensurf tmat bsdf%d - - - %d %d %s", n+1,
150 >                                                GRIDRES-1, GRIDRES-1, validf);
151                  fp = popen(buf, "w");
152                  if (fp == NULL) {
153                          fprintf(stderr, "%s: cannot open '| %s'\n", progname, buf);
# Line 156 | Line 165 | main(int argc, char *argv[])
165                          } else
166                                  bsdf = eval_rbfrep(rbf, odir) /
167                                                  (output_orient*odir[2]);
168 <                        bsdf = log(bsdf) - min_log;
168 >                        bsdf = log(bsdf + 1e-5) - min_log;
169                          fprintf(fp, "%.8e %.8e %.8e\n",
170                                          odir[0]*bsdf, odir[1]*bsdf, odir[2]*bsdf);
171                      }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines