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.52 by greg, Tue Jun 26 14:42:18 2018 UTC vs.
Revision 2.56 by greg, Tue Nov 13 19:58:33 2018 UTC

# 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 552 | Line 555 | sample_sdf(BSDFDAT *ndp, int sflags)
555                          rayvalue(&tr);
556                          multcolor(tr.rcol, tr.rcoef);
557                          addcolor(ndp->pr->rcol, tr.rcol);
558 +                        ndp->pr->rxt = ndp->pr->rot + raydistance(&tr);
559                          ++ntotal;
560                          b = bright(ndp->cthru);
561                  } else
# Line 631 | Line 635 | m_bsdf(OBJREC *m, RAY *r)
635                                                  /* get BSDF data */
636          nd.sd = loadBSDF(m->oargs.sarg[hasthick]);
637                                                  /* early shadow check #2 */
638 <        if (r->crtype & SHADOW && (nd.sd->tf == NULL) & (nd.sd->tb == NULL))
638 >        if (r->crtype & SHADOW && (nd.sd->tf == NULL) & (nd.sd->tb == NULL)) {
639 >                SDfreeCache(nd.sd);
640                  return(1);
641 +        }
642                                                  /* diffuse reflectance */
643          if (hitfront) {
644                  cvt_sdcolor(nd.rdiff, &nd.sd->rLambFront);
# Line 688 | Line 694 | m_bsdf(OBJREC *m, RAY *r)
694          }
695          if (ec) {
696                  objerror(m, WARNING, "Illegal orientation vector");
697 +                SDfreeCache(nd.sd);
698                  return(1);
699          }
700          setcolor(nd.cthru, 0, 0, 0);            /* consider through component */
# Line 695 | Line 702 | m_bsdf(OBJREC *m, RAY *r)
702                  compute_through(&nd);
703                  if (r->crtype & SHADOW) {
704                          RAY     tr;             /* attempt to pass shadow ray */
705 +                        SDfreeCache(nd.sd);
706                          if (rayorigin(&tr, TRANS, r, nd.cthru) < 0)
707                                  return(1);      /* no through component */
708                          VCOPY(tr.rdir, r->rdir);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines