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

Comparing ray/src/common/bsdf.c (file contents):
Revision 2.6 by greg, Fri Sep 3 23:53:50 2010 UTC vs.
Revision 2.8 by greg, Sun Sep 26 15:43:26 2010 UTC

# Line 249 | Line 249 | to_meters(             /* return factor to convert given unit to
249          if (!strcasecmp(unit, "Foot")) return(.3048);
250          if (!strcasecmp(unit, "Inch")) return(.0254);
251          if (!strcasecmp(unit, "Centimeter")) return(.01);
252 +        if (!strcasecmp(unit, "Millimeter")) return(.001);
253          sprintf(errmsg, "unknown dimensional unit '%s'", unit);
254          error(USER, errmsg);
255   }
# Line 376 | Line 377 | check_bsdf_data(       /* check that BSDF data is sane */
377   )
378   {
379          double          *omega_iarr, *omega_oarr;
380 <        double          dom, contrib, hemi_total;
380 >        double          dom, contrib, hemi_total, full_total;
381          int             nneg;
382          FVECT           v;
383          int             i, o;
# Line 445 | Line 446 | check_bsdf_data(       /* check that BSDF data is sane */
446                                  BSDF_value(dp,i,o) = .0f;
447                          }
448                  }
449 <                if (hemi_total > 1.02) {
449 >                if (hemi_total > 1.01) {
450                          sprintf(errmsg,
451                          "incoming BSDF direction %d passes %.1f%% of light",
452                                          i, 100.*hemi_total);
# Line 456 | Line 457 | check_bsdf_data(       /* check that BSDF data is sane */
457                  sprintf(errmsg, "%d negative BSDF values (ignored)", nneg);
458                  error(WARNING, errmsg);
459          }
460 <                                        /* reverse roles and check again */
460 >        full_total = .0;                /* reverse roles and check again */
461          for (o = 0; o < dp->nout; o++) {
462                  hemi_total = .0;
463                  for (i = dp->ninc; i--; )
464                          hemi_total += BSDF_value(dp,i,o) * omega_iarr[i];
465  
466 <                if (hemi_total > 1.02) {
466 >                if (hemi_total > 1.01) {
467                          sprintf(errmsg,
468                          "outgoing BSDF direction %d collects %.1f%% of light",
469                                          o, 100.*hemi_total);
470                          error(WARNING, errmsg);
471                  }
472 +                full_total += hemi_total*omega_oarr[o];
473 +        }
474 +        full_total /= PI;
475 +        if (full_total > 1.00001) {
476 +                sprintf(errmsg, "BSDF transfers %.4f%% of light",
477 +                                100.*full_total);
478 +                error(WARNING, errmsg);
479          }
480          free(omega_iarr); free(omega_oarr);
481          return(1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines