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.42 by greg, Tue Nov 28 22:17:00 2017 UTC vs.
Revision 2.43 by greg, Fri Dec 1 02:45:14 2017 UTC

# Line 154 | Line 154 | compute_through(BSDFDAT *ndp)
154                  goto baderror;
155          if (tomega > 1.5*dfp->minProjSA)
156                  return;                         /* not really a peak? */
157 +        tomega /= fabs(pdir[2]);                /* remove cosine factor */
158          if ((bright(vpeak) - ndp->sd->tLamb.cieY*(1./PI))*tomega <= .001)
159                  return;                         /* < 0.1% transmission */
160          for (i = 3; i--; )                      /* remove peak from average */
# Line 187 | Line 188 | bsdf_jitter(FVECT vres, BSDFDAT *ndp, double sr_psa)
188   static int
189   direct_specular_OK(COLOR cval, FVECT ldir, double omega, BSDFDAT *ndp)
190   {
191 <        int     nsamp, ok = 0;
191 >        int     nsamp;
192 >        double  wtot = 0;
193          FVECT   vsrc, vsmp, vjit;
194          double  tomega, tomega2;
195          double  sf, tsr, sd[2];
# Line 272 | Line 274 | direct_specular_OK(COLOR cval, FVECT ldir, double omeg
274                  if (tomega2 < .12*tomega)
275                          continue;       /* not safe to include */
276                  cvt_sdcolor(csmp, &sv);
277 <                addcolor(cval, csmp);   /* else average it in */
278 <                ++ok;
277 >                                        /* weight average by Y */
278 >                scalecolor(csmp, sv.cieY);
279 >                addcolor(cval, csmp);
280 >                wtot += sv.cieY;
281          }
282 <        if (!ok)                        /* no valid specular samples? */
282 >        if (wtot <= FTINY)              /* no valid specular samples? */
283                  return(0);
284  
285 <        sf = 1./(double)ok;             /* compute average BSDF */
285 >        sf = 1./wtot;                   /* weighted average BSDF */
286          scalecolor(cval, sf);
287                                          /* subtract diffuse contribution */
288          for (i = 3*(diffY > FTINY); i--; )
# Line 538 | Line 542 | sample_sdf(BSDFDAT *ndp, int sflags)
542                  } else
543                          hasthru = 0;
544          }
545 <        if (dfp->maxHemi - b <= FTINY) {        /* how specular to sample? */
545 >        if (dfp->maxHemi - b <= FTINY) {        /* have specular to sample? */
546                  b = 0;
547          } else {
548                  FVECT   vjit;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines