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

Comparing ray/src/rt/m_bsdf.c (file contents):
Revision 2.16 by greg, Wed Aug 24 04:31:13 2011 UTC vs.
Revision 2.22 by greg, Sun Sep 2 15:33:15 2012 UTC

# Line 157 | Line 157 | direct_bsdf_OK(COLOR cval, FVECT ldir, double omega, B
157          return(ok);
158   baderror:
159          objerror(ndp->mp, USER, transSDError(ec));
160 +        return(0);                      /* gratis return */
161   }
162  
163   /* Compute source contribution for BSDF (reflected & transmitted) */
# Line 379 | Line 380 | sample_sdf(BSDFDAT *ndp, int sflags)
380  
381          if (sflags == SDsampSpT) {
382                  unsc = ndp->tunsamp;
383 <                dfp = ndp->sd->tf;
383 >                if (ndp->pr->rod > 0)
384 >                        dfp = (ndp->sd->tf != NULL) ? ndp->sd->tf : ndp->sd->tb;
385 >                else
386 >                        dfp = (ndp->sd->tb != NULL) ? ndp->sd->tb : ndp->sd->tf;
387                  cvt_sdcolor(unsc, &ndp->sd->tLamb);
388          } else /* sflags == SDsampSpR */ {
389                  unsc = ndp->runsamp;
# Line 469 | Line 473 | m_bsdf(OBJREC *m, RAY *r)
473          } else {
474                  if (m->oargs.nfargs < 6) {      /* check invisible backside */
475                          if (!backvis && (nd.sd->rb == NULL) &
476 <                                                (nd.sd->tf == NULL)) {
476 >                                        (nd.sd->tb == NULL)) {
477                                  SDfreeCache(nd.sd);
478                                  raytrans(r);
479                                  return(1);
# Line 499 | Line 503 | m_bsdf(OBJREC *m, RAY *r)
503          upvec[1] = evalue(mf->ep[2]);
504          upvec[2] = evalue(mf->ep[3]);
505                                                  /* return to world coords */
506 <        if (mf->f != &unitxf) {
507 <                multv3(upvec, upvec, mf->f->xfm);
508 <                nd.thick *= mf->f->sca;
506 >        if (mf->fxp != &unitxf) {
507 >                multv3(upvec, upvec, mf->fxp->xfm);
508 >                nd.thick *= mf->fxp->sca;
509          }
510          raynormal(nd.pnorm, r);
511                                                  /* compute local BSDF xform */
# Line 514 | Line 518 | m_bsdf(OBJREC *m, RAY *r)
518          }
519          if (!ec)
520                  ec = SDinvXform(nd.fromloc, nd.toloc);
517                                                /* determine BSDF resolution */
518        if (!ec)
519                ec = SDsizeBSDF(nd.sr_vpsa, nd.vray, NULL,
520                                                SDqueryMin+SDqueryMax, nd.sd);
521          if (ec) {
522 <                objerror(m, WARNING, transSDError(ec));
523 <                SDfreeCache(nd.sd);
522 >                objerror(m, WARNING, "Illegal orientation vector");
523                  return(1);
524          }
525 +                                                /* determine BSDF resolution */
526 +        ec = SDsizeBSDF(nd.sr_vpsa, nd.vray, NULL, SDqueryMin+SDqueryMax, nd.sd);
527 +        if (ec)
528 +                objerror(m, USER, transSDError(ec));
529 +
530          nd.sr_vpsa[0] = sqrt(nd.sr_vpsa[0]);
531          nd.sr_vpsa[1] = sqrt(nd.sr_vpsa[1]);
532          if (!hitfront) {                        /* perturb normal towards hit */
# Line 556 | Line 560 | m_bsdf(OBJREC *m, RAY *r)
560                  bnorm[2] = -nd.pnorm[2];
561                  if (nd.thick != 0) {            /* proxy with offset? */
562                          VCOPY(vtmp, r->rop);
563 <                        VSUM(r->rop, vtmp, r->ron, -nd.thick);
563 >                        VSUM(r->rop, vtmp, r->ron, nd.thick);
564                          multambient(ctmp, r, bnorm);
565                          VCOPY(r->rop, vtmp);
566                  } else
# Line 566 | Line 570 | m_bsdf(OBJREC *m, RAY *r)
570                          flipsurface(r);
571          }
572                                                  /* add direct component */
573 <        if ((bright(nd.tdiff) <= FTINY) & (nd.sd->tf == NULL)) {
573 >        if ((bright(nd.tdiff) <= FTINY) & (nd.sd->tf == NULL) &
574 >                                        (nd.sd->tb == NULL)) {
575                  direct(r, dir_brdf, &nd);       /* reflection only */
576          } else if (nd.thick == 0) {
577                  direct(r, dir_bsdf, &nd);       /* thin surface scattering */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines