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

Comparing ray/src/cv/bsdf2ttree.c (file contents):
Revision 2.16 by greg, Wed May 15 17:29:30 2013 UTC vs.
Revision 2.20 by greg, Thu Oct 3 17:27:41 2013 UTC

# Line 24 | Line 24 | int                    samp_order = 6;
24   const double            ssamp_thresh = 0.35;
25                                  /* number of super-samples */
26   const int               nssamp = 100;
27 +                                /* limit on number of RBF lobes */
28 + static int              lobe_lim = 15000;
29  
30   /* Output XML prologue to stdout */
31   static void
# Line 112 | Line 114 | eval_isotropic(char *funame)
114   {
115          const int       sqres = 1<<samp_order;
116          FILE            *ofp = NULL;
117 +        int             assignD = 0;
118          char            cmd[128];
119          int             ix, ox, oy;
120          double          iovec[6];
# Line 119 | Line 122 | eval_isotropic(char *funame)
122  
123          data_prologue();                        /* begin output */
124          if (pctcull >= 0) {
125 <                sprintf(cmd, "rttree_reduce -h -a -ff -r 3 -t %f -g %d",
125 >                sprintf(cmd, "rttree_reduce -a -h -ff -r 3 -t %f -g %d",
126                                  pctcull, samp_order);
127                  fflush(stdout);
128                  ofp = popen(cmd, "w");
# Line 131 | Line 134 | eval_isotropic(char *funame)
134                  SET_FILE_BINARY(ofp);
135          } else
136                  fputs("{\n", stdout);
137 +                                                /* need to assign Dx, Dy, Dz? */
138 +        if (funame != NULL)
139 +                assignD = (fundefined(funame) < 6);
140                                                  /* run through directions */
141          for (ix = 0; ix < sqres/2; ix++) {
142                  RBFNODE *rbf = NULL;
# Line 138 | Line 144 | eval_isotropic(char *funame)
144                  iovec[1] = .0;
145                  iovec[2] = input_orient * sqrt(1. - iovec[0]*iovec[0]);
146                  if (funame == NULL)
147 <                        rbf = advect_rbf(iovec);
147 >                        rbf = advect_rbf(iovec, lobe_lim);
148                  for (ox = 0; ox < sqres; ox++) {
149                      float       last_bsdf = -1;
150                      for (oy = 0; oy < sqres; oy++) {
# Line 151 | Line 157 | eval_isotropic(char *funame)
157                          else {
158                              double      ssa[3], ssvec[6], sum;
159                              int         ssi;
160 +                            if (assignD) {
161 +                                varset("Dx", '=', -iovec[3]);
162 +                                varset("Dy", '=', -iovec[4]);
163 +                                varset("Dz", '=', -iovec[5]);
164 +                                ++eclock;
165 +                            }
166                              bsdf = funvalue(funame, 6, iovec);
167                              if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) {
168                                  sum = 0;        /* super-sample voxel */
# Line 165 | Line 177 | eval_isotropic(char *funame)
177                                      ssvec[5] = output_orient *
178                                                  sqrt(1. - ssvec[3]*ssvec[3] -
179                                                          ssvec[4]*ssvec[4]);
180 +                                    if (assignD) {
181 +                                        varset("Dx", '=', -iovec[3]);
182 +                                        varset("Dy", '=', -iovec[4]);
183 +                                        varset("Dz", '=', -iovec[5]);
184 +                                        ++eclock;
185 +                                    }
186                                      sum += funvalue(funame, 6, ssvec);
187                                  }
188                                  bsdf = sum/nssamp;
# Line 200 | Line 218 | eval_anisotropic(char *funame)
218   {
219          const int       sqres = 1<<samp_order;
220          FILE            *ofp = NULL;
221 +        int             assignD = 0;
222          char            cmd[128];
223          int             ix, iy, ox, oy;
224          double          iovec[6];
# Line 207 | Line 226 | eval_anisotropic(char *funame)
226  
227          data_prologue();                        /* begin output */
228          if (pctcull >= 0) {
229 <                sprintf(cmd, "rttree_reduce -h -a -ff -r 4 -t %f -g %d",
229 >                sprintf(cmd, "rttree_reduce%s -h -ff -r 4 -t %f -g %d",
230 >                                (input_orient>0 ^ output_orient>0) ? "" : " -a",
231                                  pctcull, samp_order);
232                  fflush(stdout);
233                  ofp = popen(cmd, "w");
# Line 218 | Line 238 | eval_anisotropic(char *funame)
238                  }
239          } else
240                  fputs("{\n", stdout);
241 +                                                /* need to assign Dx, Dy, Dz? */
242 +        if (funame != NULL)
243 +                assignD = (fundefined(funame) < 6);
244                                                  /* run through directions */
245          for (ix = 0; ix < sqres; ix++)
246              for (iy = 0; iy < sqres; iy++) {
# Line 226 | Line 249 | eval_anisotropic(char *funame)
249                  iovec[2] = input_orient *
250                                  sqrt(1. - iovec[0]*iovec[0] - iovec[1]*iovec[1]);
251                  if (funame == NULL)
252 <                        rbf = advect_rbf(iovec);
252 >                        rbf = advect_rbf(iovec, lobe_lim);
253                  for (ox = 0; ox < sqres; ox++) {
254                      float       last_bsdf = -1;
255                      for (oy = 0; oy < sqres; oy++) {
# Line 239 | Line 262 | eval_anisotropic(char *funame)
262                          else {
263                              double      ssa[4], ssvec[6], sum;
264                              int         ssi;
265 +                            if (assignD) {
266 +                                varset("Dx", '=', -iovec[3]);
267 +                                varset("Dy", '=', -iovec[4]);
268 +                                varset("Dz", '=', -iovec[5]);
269 +                                ++eclock;
270 +                            }
271                              bsdf = funvalue(funame, 6, iovec);
272                              if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) {
273                                  sum = 0;        /* super-sample voxel */
# Line 254 | Line 283 | eval_anisotropic(char *funame)
283                                      ssvec[5] = output_orient *
284                                                  sqrt(1. - ssvec[3]*ssvec[3] -
285                                                          ssvec[4]*ssvec[4]);
286 +                                    if (assignD) {
287 +                                        varset("Dx", '=', -iovec[3]);
288 +                                        varset("Dy", '=', -iovec[4]);
289 +                                        varset("Dz", '=', -iovec[5]);
290 +                                        ++eclock;
291 +                                    }
292                                      sum += funvalue(funame, 6, ssvec);
293                                  }
294                                  bsdf = sum/nssamp;
# Line 324 | Line 359 | main(int argc, char *argv[])
359                  case 'g':
360                          samp_order = atoi(argv[++i]);
361                          break;
362 +                case 'l':
363 +                        lobe_lim = atoi(argv[++i]);
364 +                        break;
365                  default:
366                          goto userr;
367                  }
368          if (single_plane_incident >= 0) {       /* function-based BSDF? */
369                  void    (*evf)(char *s) = single_plane_incident ?
370                                  &eval_isotropic : &eval_anisotropic;
371 <                if (i != argc-1 || fundefined(argv[i]) != 6) {
371 >                if (i != argc-1 || fundefined(argv[i]) < 3) {
372                          fprintf(stderr,
373          "%s: need single function with 6 arguments: bsdf(ix,iy,iz,ox,oy,oz)\n",
374                                          progname);
375 +                        fprintf(stderr, "\tor 3 arguments using Dx,Dy,Dz: bsdf(ix,iy,iz)\n",
376 +                                        progname);
377                          goto userr;
378                  }
379 +                ++eclock;
380                  xml_prologue(argc, argv);       /* start XML output */
381                  if (dofwd) {
382                          input_orient = -1;
# Line 388 | Line 429 | main(int argc, char *argv[])
429          return(0);
430   userr:
431          fprintf(stderr,
432 <        "Usage: %s [-g Nlog2][-t pctcull] [bsdf.sir ..] > bsdf.xml\n",
432 >        "Usage: %s [-g Nlog2][-t pctcull][-l maxlobes] [bsdf.sir ..] > bsdf.xml\n",
433                                  progname);
434          fprintf(stderr,
435          "   or: %s -t{3|4} [-g Nlog2][-t pctcull][{+|-}for[ward]][{+|-}b[ackward]][-e expr][-f file] bsdf_func > bsdf.xml\n",

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines