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.19 by greg, Thu Oct 3 17:01:02 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%s -h -ff -r 3 -t %f -g %d",
126 >                                (input_orient>0 ^ output_orient>0) ? "" : " -a",
127                                  pctcull, samp_order);
128                  fflush(stdout);
129                  ofp = popen(cmd, "w");
# Line 131 | Line 135 | eval_isotropic(char *funame)
135                  SET_FILE_BINARY(ofp);
136          } else
137                  fputs("{\n", stdout);
138 +                                                /* need to assign Dx, Dy, Dz? */
139 +        if (funame != NULL)
140 +                assignD = (fundefined(funame) < 6);
141                                                  /* run through directions */
142          for (ix = 0; ix < sqres/2; ix++) {
143                  RBFNODE *rbf = NULL;
# Line 138 | Line 145 | eval_isotropic(char *funame)
145                  iovec[1] = .0;
146                  iovec[2] = input_orient * sqrt(1. - iovec[0]*iovec[0]);
147                  if (funame == NULL)
148 <                        rbf = advect_rbf(iovec);
148 >                        rbf = advect_rbf(iovec, lobe_lim);
149                  for (ox = 0; ox < sqres; ox++) {
150                      float       last_bsdf = -1;
151                      for (oy = 0; oy < sqres; oy++) {
# Line 151 | Line 158 | eval_isotropic(char *funame)
158                          else {
159                              double      ssa[3], ssvec[6], sum;
160                              int         ssi;
161 +                            if (assignD) {
162 +                                varset("Dx", '=', -iovec[3]);
163 +                                varset("Dy", '=', -iovec[4]);
164 +                                varset("Dz", '=', -iovec[5]);
165 +                                ++eclock;
166 +                            }
167                              bsdf = funvalue(funame, 6, iovec);
168                              if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) {
169                                  sum = 0;        /* super-sample voxel */
# Line 165 | Line 178 | eval_isotropic(char *funame)
178                                      ssvec[5] = output_orient *
179                                                  sqrt(1. - ssvec[3]*ssvec[3] -
180                                                          ssvec[4]*ssvec[4]);
181 +                                    if (assignD) {
182 +                                        varset("Dx", '=', -iovec[3]);
183 +                                        varset("Dy", '=', -iovec[4]);
184 +                                        varset("Dz", '=', -iovec[5]);
185 +                                        ++eclock;
186 +                                    }
187                                      sum += funvalue(funame, 6, ssvec);
188                                  }
189                                  bsdf = sum/nssamp;
# Line 200 | Line 219 | eval_anisotropic(char *funame)
219   {
220          const int       sqres = 1<<samp_order;
221          FILE            *ofp = NULL;
222 +        int             assignD = 0;
223          char            cmd[128];
224          int             ix, iy, ox, oy;
225          double          iovec[6];
# Line 207 | Line 227 | eval_anisotropic(char *funame)
227  
228          data_prologue();                        /* begin output */
229          if (pctcull >= 0) {
230 <                sprintf(cmd, "rttree_reduce -h -a -ff -r 4 -t %f -g %d",
230 >                sprintf(cmd, "rttree_reduce%s -h -ff -r 4 -t %f -g %d",
231 >                                (input_orient>0 ^ output_orient>0) ? "" : " -a",
232                                  pctcull, samp_order);
233                  fflush(stdout);
234                  ofp = popen(cmd, "w");
# Line 218 | Line 239 | eval_anisotropic(char *funame)
239                  }
240          } else
241                  fputs("{\n", stdout);
242 +                                                /* need to assign Dx, Dy, Dz? */
243 +        if (funame != NULL)
244 +                assignD = (fundefined(funame) < 6);
245                                                  /* run through directions */
246          for (ix = 0; ix < sqres; ix++)
247              for (iy = 0; iy < sqres; iy++) {
# Line 226 | Line 250 | eval_anisotropic(char *funame)
250                  iovec[2] = input_orient *
251                                  sqrt(1. - iovec[0]*iovec[0] - iovec[1]*iovec[1]);
252                  if (funame == NULL)
253 <                        rbf = advect_rbf(iovec);
253 >                        rbf = advect_rbf(iovec, lobe_lim);
254                  for (ox = 0; ox < sqres; ox++) {
255                      float       last_bsdf = -1;
256                      for (oy = 0; oy < sqres; oy++) {
# Line 239 | Line 263 | eval_anisotropic(char *funame)
263                          else {
264                              double      ssa[4], ssvec[6], sum;
265                              int         ssi;
266 +                            if (assignD) {
267 +                                varset("Dx", '=', -iovec[3]);
268 +                                varset("Dy", '=', -iovec[4]);
269 +                                varset("Dz", '=', -iovec[5]);
270 +                                ++eclock;
271 +                            }
272                              bsdf = funvalue(funame, 6, iovec);
273                              if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) {
274                                  sum = 0;        /* super-sample voxel */
# Line 254 | Line 284 | eval_anisotropic(char *funame)
284                                      ssvec[5] = output_orient *
285                                                  sqrt(1. - ssvec[3]*ssvec[3] -
286                                                          ssvec[4]*ssvec[4]);
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, ssvec);
294                                  }
295                                  bsdf = sum/nssamp;
# Line 324 | Line 360 | main(int argc, char *argv[])
360                  case 'g':
361                          samp_order = atoi(argv[++i]);
362                          break;
363 +                case 'l':
364 +                        lobe_lim = atoi(argv[++i]);
365 +                        break;
366                  default:
367                          goto userr;
368                  }
369          if (single_plane_incident >= 0) {       /* function-based BSDF? */
370                  void    (*evf)(char *s) = single_plane_incident ?
371                                  &eval_isotropic : &eval_anisotropic;
372 <                if (i != argc-1 || fundefined(argv[i]) != 6) {
372 >                if (i != argc-1 || fundefined(argv[i]) < 3) {
373                          fprintf(stderr,
374          "%s: need single function with 6 arguments: bsdf(ix,iy,iz,ox,oy,oz)\n",
375                                          progname);
376 +                        fprintf(stderr, "\tor 3 arguments using Dx,Dy,Dz: bsdf(ix,iy,iz)\n",
377 +                                        progname);
378                          goto userr;
379                  }
380 +                ++eclock;
381                  xml_prologue(argc, argv);       /* start XML output */
382                  if (dofwd) {
383                          input_orient = -1;
# Line 388 | Line 430 | main(int argc, char *argv[])
430          return(0);
431   userr:
432          fprintf(stderr,
433 <        "Usage: %s [-g Nlog2][-t pctcull] [bsdf.sir ..] > bsdf.xml\n",
433 >        "Usage: %s [-g Nlog2][-t pctcull][-l maxlobes] [bsdf.sir ..] > bsdf.xml\n",
434                                  progname);
435          fprintf(stderr,
436          "   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