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.41 by greg, Wed May 31 17:25:21 2017 UTC vs.
Revision 2.42 by greg, Thu Jan 4 23:28:54 2018 UTC

# Line 129 | Line 129 | static void
129   eval_isotropic(char *funame)
130   {
131          const int       sqres = 1<<samp_order;
132 +        const double    sqfact = 1./(double)sqres;
133          FILE            *ofp, *uvfp[2];
134          int             assignD = 0;
135          char            cmd[128];
# Line 192 | Line 193 | eval_isotropic(char *funame)
193                                                  /* run through directions */
194          for (ix = 0; ix < sqres/2; ix++) {
195                  RBFNODE *rbf = NULL;
196 <                iovec[0] = 2.*(ix+.5)/sqres - 1.;
196 >                iovec[0] = 2.*sqfact*(ix+.5) - 1.;
197                  iovec[1] = .0;
198                  iovec[2] = input_orient * sqrt(1. - iovec[0]*iovec[0]);
199                  if (funame == NULL)
# Line 200 | Line 201 | eval_isotropic(char *funame)
201                  for (ox = 0; ox < sqres; ox++) {
202                      float       last_bsdf = -1;
203                      for (oy = 0; oy < sqres; oy++) {
204 <                        SDsquare2disk(iovec+3, (ox+.5)/sqres, (oy+.5)/sqres);
204 >                        SDsquare2disk(iovec+3, (ox+.5)*sqfact, (oy+.5)*sqfact);
205                          iovec[5] = output_orient *
206                                  sqrt(1. - iovec[3]*iovec[3] - iovec[4]*iovec[4]);
207                          if (funame == NULL) {
208                              SDValue     sdv;
209                              eval_rbfcol(&sdv, rbf, iovec+3);
210                              bsdf = sdv.cieY;
211 + #if (NSSAMP > 0)
212 +                            if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) {
213 +                                int     ssi;
214 +                                double  ssa[2], sum = 0, usum = 0, vsum = 0;
215 +                                                /* super-sample voxel */
216 +                                for (ssi = NSSAMP; ssi--; ) {
217 +                                    SDmultiSamp(ssa, 2, (ssi+frandom()) *
218 +                                                        (1./NSSAMP));
219 +                                    SDsquare2disk(iovec+3, (ox+ssa[0])*sqfact,
220 +                                                        (oy+ssa[1])*sqfact);
221 +                                    iovec[5] = output_orient *
222 +                                        sqrt(1. - iovec[3]*iovec[3] - iovec[4]*iovec[4]);
223 +                                    eval_rbfcol(&sdv, rbf, iovec+3);
224 +                                    sum += sdv.cieY;
225 +                                    if (rbf_colorimetry == RBCtristimulus) {
226 +                                        sdv.cieY /=
227 +                                            -2.*sdv.spec.cx + 12.*sdv.spec.cy + 3.;
228 +                                        usum += 4.*sdv.spec.cx * sdv.cieY;
229 +                                        vsum += 9.*sdv.spec.cy * sdv.cieY;
230 +                                    }
231 +                                }
232 +                                bsdf = sum * (1./NSSAMP);
233 +                                if (rbf_colorimetry == RBCtristimulus) {
234 +                                    uv[0] = usum / (sum+FTINY);
235 +                                    uv[1] = vsum / (sum+FTINY);
236 +                                }
237 +                            } else
238 + #endif
239                              if (rbf_colorimetry == RBCtristimulus) {
240                                  uv[0] = uv[1] = 1. /
241                                      (-2.*sdv.spec.cx + 12.*sdv.spec.cy + 3.);
# Line 229 | Line 258 | eval_isotropic(char *funame)
258                                  for (ssi = NSSAMP; ssi--; ) {
259                                      SDmultiSamp(ssa, 3, (ssi+frandom()) *
260                                                          (1./NSSAMP));
261 <                                    ssvec[0] = 2.*(ix+ssa[0])/sqres - 1.;
261 >                                    ssvec[0] = 2.*sqfact*(ix+ssa[0]) - 1.;
262                                      ssvec[1] = .0;
263                                      ssvec[2] = input_orient *
264                                                  sqrt(1. - ssvec[0]*ssvec[0]);
265 <                                    SDsquare2disk(ssvec+3, (ox+ssa[1])/sqres,
266 <                                                (oy+ssa[2])/sqres);
265 >                                    SDsquare2disk(ssvec+3, (ox+ssa[1])*sqfact,
266 >                                                (oy+ssa[2])*sqfact);
267                                      ssvec[5] = output_orient *
268                                                  sqrt(1. - ssvec[3]*ssvec[3] -
269                                                          ssvec[4]*ssvec[4]);
# Line 246 | Line 275 | eval_isotropic(char *funame)
275                                      }
276                                      sum += funvalue(funame, 6, ssvec);
277                                  }
278 <                                bsdf = sum/NSSAMP;
278 >                                bsdf = sum * (1./NSSAMP);
279                              }
280   #endif
281                          }
# Line 269 | Line 298 | eval_isotropic(char *funame)
298                  }
299                  if (rbf != NULL)
300                          free(rbf);
301 <                prog_show((ix+1.)*(2./sqres));
301 >                prog_show((ix+1.)*(2.*sqfact));
302          }
303          prog_done();
304          if (pctcull >= 0) {                     /* finish output */
# Line 314 | Line 343 | static void
343   eval_anisotropic(char *funame)
344   {
345          const int       sqres = 1<<samp_order;
346 +        const double    sqfact = 1./(double)sqres;
347          FILE            *ofp, *uvfp[2];
348          int             assignD = 0;
349          char            cmd[128];
# Line 383 | Line 413 | eval_anisotropic(char *funame)
413          for (ix = 0; ix < sqres; ix++)
414              for (iy = 0; iy < sqres; iy++) {
415                  RBFNODE *rbf = NULL;            /* Klems reversal */
416 <                SDsquare2disk(iovec, 1.-(ix+.5)/sqres, 1.-(iy+.5)/sqres);
416 >                SDsquare2disk(iovec, 1.-(ix+.5)*sqfact, 1.-(iy+.5)*sqfact);
417                  iovec[2] = input_orient *
418                                  sqrt(1. - iovec[0]*iovec[0] - iovec[1]*iovec[1]);
419                  if (funame == NULL)
# Line 391 | Line 421 | eval_anisotropic(char *funame)
421                  for (ox = 0; ox < sqres; ox++) {
422                      float       last_bsdf = -1;
423                      for (oy = 0; oy < sqres; oy++) {
424 <                        SDsquare2disk(iovec+3, (ox+.5)/sqres, (oy+.5)/sqres);
424 >                        SDsquare2disk(iovec+3, (ox+.5)*sqfact, (oy+.5)*sqfact);
425                          iovec[5] = output_orient *
426                                  sqrt(1. - iovec[3]*iovec[3] - iovec[4]*iovec[4]);
427                          if (funame == NULL) {
428                              SDValue     sdv;
429                              eval_rbfcol(&sdv, rbf, iovec+3);
430                              bsdf = sdv.cieY;
431 + #if (NSSAMP > 0)
432 +                            if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) {
433 +                                int     ssi;
434 +                                double  ssa[2], sum = 0, usum = 0, vsum = 0;
435 +                                                /* super-sample voxel */
436 +                                for (ssi = NSSAMP; ssi--; ) {
437 +                                    SDmultiSamp(ssa, 2, (ssi+frandom()) *
438 +                                                        (1./NSSAMP));
439 +                                    SDsquare2disk(iovec+3, (ox+ssa[0])*sqfact,
440 +                                                        (oy+ssa[1])*sqfact);
441 +                                    iovec[5] = output_orient *
442 +                                        sqrt(1. - iovec[3]*iovec[3] - iovec[4]*iovec[4]);
443 +                                    eval_rbfcol(&sdv, rbf, iovec+3);
444 +                                    sum += sdv.cieY;
445 +                                    if (rbf_colorimetry == RBCtristimulus) {
446 +                                        sdv.cieY /=
447 +                                            -2.*sdv.spec.cx + 12.*sdv.spec.cy + 3.;
448 +                                        usum += 4.*sdv.spec.cx * sdv.cieY;
449 +                                        vsum += 9.*sdv.spec.cy * sdv.cieY;
450 +                                    }
451 +                                }
452 +                                bsdf = sum * (1./NSSAMP);
453 +                                if (rbf_colorimetry == RBCtristimulus) {
454 +                                    uv[0] = usum / (sum+FTINY);
455 +                                    uv[1] = vsum / (sum+FTINY);
456 +                                }
457 +                            } else
458 + #endif
459                              if (rbf_colorimetry == RBCtristimulus) {
460                                  uv[0] = uv[1] = 1. /
461                                      (-2.*sdv.spec.cx + 12.*sdv.spec.cy + 3.);
# Line 420 | Line 478 | eval_anisotropic(char *funame)
478                                  for (ssi = NSSAMP; ssi--; ) {
479                                      SDmultiSamp(ssa, 4, (ssi+frandom()) *
480                                                          (1./NSSAMP));
481 <                                    SDsquare2disk(ssvec, 1.-(ix+ssa[0])/sqres,
482 <                                                1.-(iy+ssa[1])/sqres);
481 >                                    SDsquare2disk(ssvec, 1.-(ix+ssa[0])*sqfact,
482 >                                                1.-(iy+ssa[1])*sqfact);
483                                      ssvec[2] = input_orient *
484                                                  sqrt(1. - ssvec[0]*ssvec[0] -
485                                                          ssvec[1]*ssvec[1]);
486 <                                    SDsquare2disk(ssvec+3, (ox+ssa[2])/sqres,
487 <                                                (oy+ssa[3])/sqres);
486 >                                    SDsquare2disk(ssvec+3, (ox+ssa[2])*sqfact,
487 >                                                (oy+ssa[3])*sqfact);
488                                      ssvec[5] = output_orient *
489                                                  sqrt(1. - ssvec[3]*ssvec[3] -
490                                                          ssvec[4]*ssvec[4]);
# Line 438 | Line 496 | eval_anisotropic(char *funame)
496                                      }
497                                      sum += funvalue(funame, 6, ssvec);
498                                  }
499 <                                bsdf = sum/NSSAMP;
499 >                                bsdf = sum * (1./NSSAMP);
500                              }
501   #endif
502                          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines