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.14 by greg, Sun Aug 21 22:38:12 2011 UTC vs.
Revision 2.15 by greg, Mon Aug 22 16:00:47 2011 UTC

# Line 82 | Line 82 | typedef struct {
82  
83   /* Jitter ray sample according to projected solid angle and specjitter */
84   static void
85 < bsdf_jitter(FVECT vres, BSDFDAT *ndp, int domax)
85 > bsdf_jitter(FVECT vres, BSDFDAT *ndp, double sr_psa)
86   {
87        double  sr_psa = ndp->sr_vpsa[domax];
88
87          VCOPY(vres, ndp->vray);
88          if (specjitter < 1.)
89                  sr_psa *= specjitter;
# Line 100 | Line 98 | bsdf_jitter(FVECT vres, BSDFDAT *ndp, int domax)
98   static int
99   direct_bsdf_OK(COLOR cval, FVECT ldir, double omega, BSDFDAT *ndp)
100   {
101 <        int     nsamp = 1, ok = 0;
101 >        int     nsamp, ok = 0;
102          FVECT   vsrc, vsmp, vjit;
103          double  tomega;
104 <        double  sf, sd[2];
104 >        double  sf, tsr, sd[2];
105          COLOR   csmp;
106          SDValue sv;
107          SDError ec;
# Line 119 | Line 117 | direct_bsdf_OK(COLOR cval, FVECT ldir, double omega, B
117                  if (dx*dx + dy*dy <= omega*(1./PI))
118                          return(0);
119          }
120 <        if (specjitter > FTINY) {       /* assign number of samples */
121 <                ec = SDsizeBSDF(&tomega, ndp->vray, vsrc, SDqueryMin, ndp->sd);
122 <                if (ec)
123 <                        goto baderror;
124 <                sf = specjitter * ndp->pr->rweight;
125 <                if (tomega <= omega*.01)
126 <                        nsamp = 100.*sf + .5;
127 <                else
128 <                        nsamp = 4.*sf*omega/tomega + .5;
129 <                nsamp += !nsamp;
132 <        }
133 <        sf = sqrt(omega);
120 >                                        /* assign number of samples */
121 >        ec = SDsizeBSDF(&tomega, ndp->vray, vsrc, SDqueryMin, ndp->sd);
122 >        if (ec)
123 >                goto baderror;
124 >        sf = specjitter * ndp->pr->rweight;
125 >        if (25.*tomega <= omega)
126 >                nsamp = 100.*sf + .5;
127 >        else
128 >                nsamp = 4.*sf*omega/tomega + .5;
129 >        nsamp += !nsamp;
130          setcolor(cval, .0, .0, .0);     /* sample our source area */
131 +        sf = sqrt(omega);
132 +        tsr = sqrt(tomega);
133          for (i = nsamp; i--; ) {
134                  VCOPY(vsmp, vsrc);      /* jitter query directions */
135                  if (nsamp > 1) {
# Line 143 | Line 141 | direct_bsdf_OK(COLOR cval, FVECT ldir, double omega, B
141                                  continue;
142                          }
143                  }
144 <                bsdf_jitter(vjit, ndp, 0);
144 >                bsdf_jitter(vjit, ndp, tsr);
145                                          /* compute BSDF */
146                  ec = SDevalBSDF(&sv, vjit, vsmp, ndp->sd);
147                  if (ec)
# Line 333 | Line 331 | sample_sdcomp(BSDFDAT *ndp, SDComponent *dcp, int usep
331          }
332                                                  /* run through our samples */
333          for (nsent = 0; nsent < nstarget; nsent++) {
334 <                if (nstarget == 1)              /* stratify random variable */
334 >                if (nstarget == 1) {            /* stratify random variable */
335                          xrand = urand(ilhash(dimlist,ndims)+samplendx);
336 <                else
336 >                        if (specjitter < 1.)
337 >                                xrand = .5 + specjitter*(xrand-.5);
338 >                } else {
339                          xrand = (nsent + frandom())/(double)nstarget;
340 +                }
341                  SDerrorDetail[0] = '\0';        /* sample direction & coef. */
342 <                bsdf_jitter(vsmp, ndp, 0);
342 >                bsdf_jitter(vsmp, ndp, ndp->sr_vpsa[0]);
343                  ec = SDsampComponent(&bsv, vsmp, xrand, dcp);
344                  if (ec)
345                          objerror(ndp->mp, USER, transSDError(ec));
# Line 399 | Line 400 | sample_sdf(BSDFDAT *ndp, int sflags)
400                          FVECT   vjit;
401                          double  d;
402                          COLOR   ctmp;
403 <                        bsdf_jitter(vjit, ndp, 1);
403 >                        bsdf_jitter(vjit, ndp, ndp->sr_vpsa[1]);
404                          d = SDdirectHemi(vjit, sflags, ndp->sd);
405                          if (sflags == SDsampSpT) {
406                                  copycolor(ctmp, ndp->pr->pcol);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines