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.50 by greg, Mon Jun 25 20:49:10 2018 UTC vs.
Revision 2.55 by greg, Tue Aug 21 23:31:01 2018 UTC

# Line 36 | Line 36 | static const char RCSid[] = "$Id$";
36   *  hides geometry in front of the surface when rays hit from behind,
37   *  and applies only the transmission and backside reflectance properties.
38   *  Reflection is ignored on the hidden side, as those rays pass through.
39 < *      For the MAT_SBSDF type, we check for a strong "through" component.
39 > *      For the MAT_ABSDF type, we check for a strong "through" component.
40   *  Such a component will cause direct rays to pass through unscattered.
41   *  A separate test prevents over-counting by dropping samples that are
42   *  too close to this "through" direction.  BSDFs with such a through direction
43   *  will also have a view component, meaning they are somewhat see-through.
44 < *  A MAT_BSDF type with zero thickness behaves the same as a MAT_SBSDF
44 > *  A MAT_BSDF type with zero thickness behaves the same as a MAT_ABSDF
45   *  type with no strong through component.
46   *      The "up" vector for the BSDF is given by three variables, defined
47   *  (along with the thickness) by the named function file, or '.' if none.
# Line 55 | Line 55 | static const char RCSid[] = "$Id$";
55   *  not multiplied.  However, patterns affect this material as a multiplier
56   *  on everything except non-diffuse reflection.
57   *
58 < *  Arguments for MAT_SBSDF are:
58 > *  Arguments for MAT_ABSDF are:
59   *      5+      BSDFfile        ux uy uz        funcfile        transform
60   *      0
61   *      0|3|6|9 rdf     gdf     bdf
# Line 86 | Line 86 | typedef struct {
86          RREAL   toloc[3][3];    /* world to local BSDF coords */
87          RREAL   fromloc[3][3];  /* local BSDF coords to world */
88          double  thick;          /* surface thickness */
89 <        COLOR   cthru;          /* "through" component for MAT_SBSDF */
89 >        COLOR   cthru;          /* "through" component for MAT_ABSDF */
90          SDData  *sd;            /* loaded BSDF data */
91          COLOR   rdiff;          /* diffuse reflection */
92          COLOR   runsamp;        /* BSDF hemispherical reflection */
# Line 96 | Line 96 | typedef struct {
96  
97   #define cvt_sdcolor(cv, svp)    ccy2rgb(&(svp)->spec, (svp)->cieY, cv)
98  
99 < /* Compute "through" component color for MAT_SBSDF */
99 > /* Compute "through" component color for MAT_ABSDF */
100   static void
101   compute_through(BSDFDAT *ndp)
102   {
# Line 162 | Line 162 | compute_through(BSDFDAT *ndp)
162                  goto baderror;
163          if (tomega > 1.5*dfp->minProjSA)
164                  return;                         /* not really a peak? */
165        tomega /= fabs(pdir[2]);                /* remove cosine factor */
165          if ((bright(vpeak) - ndp->sd->tLamb.cieY*(1./PI))*tomega <= .001)
166                  return;                         /* < 0.1% transmission */
167          for (i = 3; i--; )                      /* remove peak from average */
# Line 236 | Line 235 | direct_specular_OK(COLOR cval, FVECT ldir, double omeg
235                  diffY = 0;
236                  setcolor(cdiff,  0, 0, 0);
237          }
238 <                                        /* need projected solid angles */
238 >                                        /* need projected solid angle */
239          omega *= fabs(vsrc[2]);
241        ec = SDsizeBSDF(&tomega, ndp->vray, vsrc, SDqueryMin, ndp->sd);
242        if (ec)
243                goto baderror;
240                                          /* check indirect over-counting */
241          if ((vsrc[2] > 0) ^ (ndp->vray[2] > 0) && bright(ndp->cthru) > FTINY) {
242 <                double  dx = vsrc[0] + ndp->vray[0];
243 <                double  dy = vsrc[1] + ndp->vray[1];
244 <                if (dx*dx + dy*dy <= (2.5*4./PI)*(omega + tomega +
245 <                                                2.*sqrt(omega*tomega)))
242 >                double          dx = vsrc[0] + ndp->vray[0];
243 >                double          dy = vsrc[1] + ndp->vray[1];
244 >                SDSpectralDF    *dfp = (ndp->pr->rod > 0) ?
245 >                        ((ndp->sd->tf != NULL) ? ndp->sd->tf : ndp->sd->tb) :
246 >                        ((ndp->sd->tb != NULL) ? ndp->sd->tb : ndp->sd->tf) ;
247 >
248 >                if (dx*dx + dy*dy <= (2.5*4./PI)*(omega + dfp->minProjSA +
249 >                                                2.*sqrt(omega*dfp->minProjSA)))
250                          return(0);
251          }
252 +        ec = SDsizeBSDF(&tomega, ndp->vray, vsrc, SDqueryMin, ndp->sd);
253 +        if (ec)
254 +                goto baderror;
255                                          /* assign number of samples */
256          sf = specjitter * ndp->pr->rweight;
257          if (tomega <= 0)
# Line 624 | Line 627 | m_bsdf(OBJREC *m, RAY *r)
627                  raytrans(r);                    /* hide our proxy */
628                  return(1);
629          }
630 +        if (hasthick && r->crtype & SHADOW)     /* early shadow check #1 */
631 +                return(1);
632          nd.mp = m;
633          nd.pr = r;
634                                                  /* get BSDF data */
635          nd.sd = loadBSDF(m->oargs.sarg[hasthick]);
636 <                                                /* early shadow check */
637 <        if (r->crtype & SHADOW && (nd.sd->tf == NULL) & (nd.sd->tb == NULL))
636 >                                                /* early shadow check #2 */
637 >        if (r->crtype & SHADOW && (nd.sd->tf == NULL) & (nd.sd->tb == NULL)) {
638 >                SDfreeCache(nd.sd);
639                  return(1);
640 +        }
641                                                  /* diffuse reflectance */
642          if (hitfront) {
643                  cvt_sdcolor(nd.rdiff, &nd.sd->rLambFront);
# Line 686 | Line 693 | m_bsdf(OBJREC *m, RAY *r)
693          }
694          if (ec) {
695                  objerror(m, WARNING, "Illegal orientation vector");
696 +                SDfreeCache(nd.sd);
697                  return(1);
698          }
699          setcolor(nd.cthru, 0, 0, 0);            /* consider through component */
700 <        if (m->otype == MAT_SBSDF) {
700 >        if (m->otype == MAT_ABSDF) {
701                  compute_through(&nd);
702                  if (r->crtype & SHADOW) {
703                          RAY     tr;             /* attempt to pass shadow ray */
704 +                        SDfreeCache(nd.sd);
705                          if (rayorigin(&tr, TRANS, r, nd.cthru) < 0)
706                                  return(1);      /* no through component */
707                          VCOPY(tr.rdir, r->rdir);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines