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.5 by greg, Sun Feb 20 06:34:19 2011 UTC vs.
Revision 2.6 by greg, Sun Feb 20 17:43:43 2011 UTC

# Line 401 | Line 401 | sample_sdf(BSDFDAT *ndp, int sflags)
401   int
402   m_bsdf(OBJREC *m, RAY *r)
403   {
404 +        int     hitfront;
405          COLOR   ctmp;
406          SDError ec;
407          FVECT   upvec, vtmp;
# Line 410 | Line 411 | m_bsdf(OBJREC *m, RAY *r)
411          if ((m->oargs.nsargs < 6) | (m->oargs.nfargs > 9) |
412                                  (m->oargs.nfargs % 3))
413                  objerror(m, USER, "bad # arguments");
414 <
414 >                                                /* record surface struck */
415 >        hitfront = (r->rod > .0);
416                                                  /* load cal file */
417          mf = getfunc(m, 5, 0x1d, 1);
418                                                  /* get thickness */
# Line 425 | Line 427 | m_bsdf(OBJREC *m, RAY *r)
427          }
428                                                  /* check other rays to pass */
429          if (nd.thick != 0 && (!(r->crtype & (SPECULAR|AMBIENT)) ||
430 <                                nd.thick > .0 ^ r->rod > .0)) {
430 >                                nd.thick > .0 ^ hitfront)) {
431                  raytrans(r);                    /* hide our proxy */
432                  return(1);
433          }
434                                                  /* get BSDF data */
435          nd.sd = loadBSDF(m->oargs.sarg[1]);
436                                                  /* diffuse reflectance */
437 <        if (r->rod > .0) {
437 >        if (hitfront) {
438                  if (m->oargs.nfargs < 3)
439                          setcolor(nd.rdiff, .0, .0, .0);
440                  else
# Line 497 | Line 499 | m_bsdf(OBJREC *m, RAY *r)
499                  SDfreeCache(nd.sd);
500                  return(1);
501          }
502 <        if (r->rod < .0) {                      /* perturb normal towards hit */
502 >        if (!hitfront) {                        /* perturb normal towards hit */
503                  nd.pnorm[0] = -nd.pnorm[0];
504                  nd.pnorm[1] = -nd.pnorm[1];
505                  nd.pnorm[2] = -nd.pnorm[2];
# Line 510 | Line 512 | m_bsdf(OBJREC *m, RAY *r)
512          copycolor(ctmp, nd.rdiff);
513          addcolor(ctmp, nd.runsamp);
514          if (bright(ctmp) > FTINY) {             /* ambient from reflection */
515 <                if (r->rod < .0)
515 >                if (!hitfront)
516                          flipsurface(r);
517                  multambient(ctmp, r, nd.pnorm);
518                  addcolor(r->rcol, ctmp);
519 <                if (r->rod < .0)
519 >                if (!hitfront)
520                          flipsurface(r);
521          }
522          copycolor(ctmp, nd.tdiff);
523          addcolor(ctmp, nd.tunsamp);
524          if (bright(ctmp) > FTINY) {             /* ambient from other side */
525                  FVECT  bnorm;
526 <                if (r->rod > .0)
526 >                if (hitfront)
527                          flipsurface(r);
528                  bnorm[0] = -nd.pnorm[0];
529                  bnorm[1] = -nd.pnorm[1];
# Line 534 | Line 536 | m_bsdf(OBJREC *m, RAY *r)
536                  } else
537                          multambient(ctmp, r, bnorm);
538                  addcolor(r->rcol, ctmp);
539 <                if (r->rod > .0)
539 >                if (hitfront)
540                          flipsurface(r);
541          }
542                                                  /* add direct component */
# Line 546 | Line 548 | m_bsdf(OBJREC *m, RAY *r)
548                  direct(r, dir_brdf, &nd);       /* reflection first */
549                  VCOPY(vtmp, r->rop);            /* offset for transmitted */
550                  VSUM(r->rop, vtmp, r->ron, -nd.thick);
551 <                direct(r, dir_btdf, &nd);
551 >                direct(r, dir_btdf, &nd);       /* separate transmission */
552                  VCOPY(r->rop, vtmp);
553          }
554                                                  /* clean up */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines