ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/ambient.c
(Generate patch)

Comparing ray/src/rt/ambient.c (file contents):
Revision 2.83 by greg, Sat Apr 26 05:15:17 2014 UTC vs.
Revision 2.84 by greg, Sat Apr 26 15:54:43 2014 UTC

# Line 52 | Line 52 | static int  nunflshed = 0;     /* number of unflushed ambi
52   #endif
53  
54  
55 static double  qambacc = 0.;            /* ambient accuracy to the 1/4 power */
55   static double  avsum = 0.;              /* computed ambient value sum (log) */
56   static unsigned int  navsum = 0;        /* number of values in avsum */
57   static unsigned int  nambvals = 0;      /* total number of indirect values */
# Line 129 | Line 128 | setambacc(                             /* set ambient accuracy */
128          double  newa
129   )
130   {
131 <        double  olda = qambacc*qambacc*qambacc*qambacc;
131 >        static double   olda;           /* remember previous setting here */
132          
133          newa *= (newa > 0);
134          if (fabs(newa - olda) >= .05*(newa + olda)) {
135 <                qambacc = sqrt(sqrt(ambacc = newa));
135 >                ambacc = newa;
136                  if (nambvals > 0)
137                          sortambvals(1);         /* rebuild tree */
138          }
# Line 357 | Line 356 | sumambient(            /* get interpolated ambient value */
356   )
357   {                       /* initial limit is 10 degrees plus ambacc radians */
358          const double    minangle = 10.0 * PI/180.;
359 <        const double    maxangle = (minangle+ambacc-PI/2.)*pow(r->rweight,0.13)
361 <                                        + PI/2.;
359 >        double          maxangle = minangle + ambacc;
360          double          wsum = 0.0;
361          FVECT           ck0;
362          int             i, j;
# Line 381 | Line 379 | sumambient(            /* get interpolated ambient value */
379                                                          at->kid+i, ck0, s);
380                  }
381                                          /* good enough? */
382 <                if (wsum > 0.04 && s > (minarad*0.8+maxarad*0.2))
382 >                if (wsum >= 0.05 && s > minarad*10.0)
383                          return(wsum);
384          }
385 +                                        /* adjust maximum angle */
386 +        if (at->alist != NULL && (at->alist->lvl <= al) & (r->rweight < 0.6))
387 +                maxangle = (maxangle - PI/2.)*pow(r->rweight,0.13) + PI/2.;
388                                          /* sum this node */
389          for (av = at->alist; av != NULL; av = av->next) {
390                  double  d, delta_r2, delta_t2;
# Line 414 | Line 415 | sumambient(            /* get interpolated ambient value */
415                   */
416                  VSUB(ck0, av->pos, r->rop);
417                  d = DOT(ck0, uvw[2]);
418 <                if (d < -minarad*qambacc-.001)
418 >                if (d < -minarad*ambacc-.001)
419                          continue;
420                  d /= av->rad[0];
421                  delta_t2 = d*d;
422 <                if (delta_t2 >= qambacc*qambacc)
422 >                if (delta_t2 >= ambacc*ambacc)
423                          continue;
424                  /*
425                   *  Elliptical radii test based on Hessian
# Line 429 | Line 430 | sumambient(            /* get interpolated ambient value */
430                  delta_t2 += d*d;
431                  d = DOT(ck0, uvw[1]) / av->rad[1];
432                  delta_t2 += d*d;
433 <                if (delta_t2 >= qambacc*qambacc)
433 >                if (delta_t2 >= ambacc*ambacc)
434                          continue;
435                  /*
436                   *  Extrapolate value and compute final weight (hat function)
437                   */
438                  extambient(ct, av, r->rop, rn, uvw);
439                  d = tfunc(maxangle, sqrt(delta_r2), 0.0) *
440 <                        tfunc(qambacc, sqrt(delta_t2), 0.0);
440 >                        tfunc(ambacc, sqrt(delta_t2), 0.0);
441                  scalecolor(ct, d);
442                  addcolor(acol, ct);
443                  wsum += d;
# Line 539 | Line 540 | avinsert(                              /* insert ambient value in our tree */
540          at = &atrunk;
541          VCOPY(ck0, thescene.cuorg);
542          s = thescene.cusize;
543 <        while (s*(OCTSCALE/2) > av->rad[1]*qambacc) {
543 >        while (s*(OCTSCALE/2) > av->rad[1]*ambacc) {
544                  if (at->kid == NULL)
545                          if ((at->kid = newambtree()) == NULL)
546                                  error(SYSTEM, "out of memory in avinsert");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines