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.21 by greg, Sat Jun 9 07:16:47 2012 UTC vs.
Revision 2.30 by greg, Wed Sep 2 18:59:01 2015 UTC

# Line 13 | Line 13 | static const char RCSid[] = "$Id$";
13   #include  "func.h"
14   #include  "bsdf.h"
15   #include  "random.h"
16 + #include  "pmapmat.h"
17  
18   /*
19   *      Arguments to this material include optional diffuse colors.
# Line 122 | Line 123 | direct_bsdf_OK(COLOR cval, FVECT ldir, double omega, B
123                          return(0);
124          }
125          sf = specjitter * ndp->pr->rweight;
126 <        if (25.*tomega <= omega)
126 >        if (tomega <= .0)
127 >                nsamp = 1;
128 >        else if (25.*tomega <= omega)
129                  nsamp = 100.*sf + .5;
130          else
131                  nsamp = 4.*sf*omega/tomega + .5;
# Line 198 | Line 201 | dir_bsdf(
201                  scalecolor(ctmp, dtmp);
202                  addcolor(cval, ctmp);
203          }
204 +        if (ambRayInPmap(np->pr))
205 +                return;         /* specular already in photon map */
206          /*
207           *  Compute scattering coefficient using BSDF.
208           */
# Line 253 | Line 258 | dir_brdf(
258                  scalecolor(ctmp, dtmp);
259                  addcolor(cval, ctmp);
260          }
261 +        if (ambRayInPmap(np->pr))
262 +                return;         /* specular already in photon map */
263          /*
264           *  Compute reflection coefficient using BSDF.
265           */
# Line 302 | Line 309 | dir_btdf(
309                  scalecolor(ctmp, dtmp);
310                  addcolor(cval, ctmp);
311          }
312 +        if (ambRayInPmap(np->pr))
313 +                return;         /* specular already in photon map */
314          /*
315           *  Compute scattering coefficient using BSDF.
316           */
# Line 380 | Line 389 | sample_sdf(BSDFDAT *ndp, int sflags)
389  
390          if (sflags == SDsampSpT) {
391                  unsc = ndp->tunsamp;
392 <                dfp = ndp->sd->tf;
392 >                if (ndp->pr->rod > 0)
393 >                        dfp = (ndp->sd->tf != NULL) ? ndp->sd->tf : ndp->sd->tb;
394 >                else
395 >                        dfp = (ndp->sd->tb != NULL) ? ndp->sd->tb : ndp->sd->tf;
396                  cvt_sdcolor(unsc, &ndp->sd->tLamb);
397          } else /* sflags == SDsampSpR */ {
398                  unsc = ndp->runsamp;
# Line 441 | Line 453 | m_bsdf(OBJREC *m, RAY *r)
453          hitfront = (r->rod > 0);
454                                                  /* load cal file */
455          mf = getfunc(m, 5, 0x1d, 1);
456 +        setfunc(m, r);
457                                                  /* get thickness */
458          nd.thick = evalue(mf->ep[0]);
459          if ((-FTINY <= nd.thick) & (nd.thick <= FTINY))
# Line 451 | Line 464 | m_bsdf(OBJREC *m, RAY *r)
464                          raytrans(r);            /* pass-through */
465                  return(1);                      /* or shadow */
466          }
467 +                                                /* check backface visibility */
468 +        if (!hitfront & !backvis) {
469 +                raytrans(r);
470 +                return(1);
471 +        }
472                                                  /* check other rays to pass */
473          if (nd.thick != 0 && (!(r->crtype & (SPECULAR|AMBIENT)) ||
474 <                                nd.thick > 0 ^ hitfront)) {
474 >                                (nd.thick > 0) ^ hitfront)) {
475                  raytrans(r);                    /* hide our proxy */
476                  return(1);
477          }
# Line 468 | Line 486 | m_bsdf(OBJREC *m, RAY *r)
486                                          m->oargs.farg[1],
487                                          m->oargs.farg[2]);
488          } else {
489 <                if (m->oargs.nfargs < 6) {      /* check invisible backside */
472 <                        if (!backvis && (nd.sd->rb == NULL) &
473 <                                                (nd.sd->tf == NULL)) {
474 <                                SDfreeCache(nd.sd);
475 <                                raytrans(r);
476 <                                return(1);
477 <                        }
489 >                if (m->oargs.nfargs < 6)
490                          setcolor(nd.rdiff, .0, .0, .0);
491 <                } else
491 >                else
492                          setcolor(nd.rdiff, m->oargs.farg[3],
493                                          m->oargs.farg[4],
494                                          m->oargs.farg[5]);
# Line 504 | Line 516 | m_bsdf(OBJREC *m, RAY *r)
516                  multv3(upvec, upvec, mf->fxp->xfm);
517                  nd.thick *= mf->fxp->sca;
518          }
519 +        if (r->rox != NULL) {
520 +                multv3(upvec, upvec, r->rox->f.xfm);
521 +                nd.thick *= r->rox->f.sca;
522 +        }
523          raynormal(nd.pnorm, r);
524                                                  /* compute local BSDF xform */
525          ec = SDcompXform(nd.toloc, nd.pnorm, upvec);
# Line 567 | Line 583 | m_bsdf(OBJREC *m, RAY *r)
583                          flipsurface(r);
584          }
585                                                  /* add direct component */
586 <        if ((bright(nd.tdiff) <= FTINY) & (nd.sd->tf == NULL)) {
586 >        if ((bright(nd.tdiff) <= FTINY) & (nd.sd->tf == NULL) &
587 >                                        (nd.sd->tb == NULL)) {
588                  direct(r, dir_brdf, &nd);       /* reflection only */
589          } else if (nd.thick == 0) {
590                  direct(r, dir_bsdf, &nd);       /* thin surface scattering */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines