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.73 by greg, Wed Apr 16 20:32:00 2014 UTC vs.
Revision 2.76 by greg, Wed Apr 23 06:04:18 2014 UTC

# Line 51 | Line 51 | static int  nunflshed = 0;     /* number of unflushed ambi
51   #define MAX_SORT_INTVL  (SORT_INTVL<<6)
52   #endif
53  
54 +
55 + static double  qambacc = 0.;            /* ambient accuracy to the 1/4 power */
56   static double  avsum = 0.;              /* computed ambient value sum (log) */
57   static unsigned int  navsum = 0;        /* number of values in avsum */
58   static unsigned int  nambvals = 0;      /* total number of indirect values */
# Line 132 | Line 134 | setambacc(                             /* set ambient accuracy */
134          if (newa < 0.0)
135                  newa = 0.0;
136          ambdiff = fabs(newa - ambacc);
137 <        if (ambdiff >= .01 && (ambacc = newa) > FTINY && nambvals > 0)
138 <                sortambvals(1);                 /* rebuild tree */
137 >        if (ambdiff >= .01 && (ambacc = newa) > FTINY) {
138 >                qambacc = sqrt(sqrt(ambacc));
139 >                if (nambvals > 0)
140 >                        sortambvals(1);         /* rebuild tree */
141 >        }
142   }
143  
144  
# Line 393 | Line 398 | sumambient(            /* get interpolated ambient value */
398                  delta_t2 = d*d;
399                  d = DOT(ck0, uvw[1]) / av->rad[1];
400                  delta_t2 += d*d;
401 <                if (delta_t2 >= ambacc*ambacc)
401 >                if (delta_t2 >= qambacc*qambacc)
402                          continue;
403                  /*
404                   *  Intersection behind test
# Line 408 | Line 413 | sumambient(            /* get interpolated ambient value */
413                   */
414                  extambient(ct, av, r->rop, rn, uvw);
415                  d = tfunc(maxangle, sqrt(delta_r2), 0.0) *
416 <                        tfunc(ambacc, sqrt(delta_t2), 0.0);
416 >                        tfunc(qambacc, sqrt(delta_t2), 0.0);
417                  scalecolor(ct, d);
418                  addcolor(acol, ct);
419                  wsum += d;
# Line 456 | Line 461 | makeambient(           /* make a new ambient value for storage
461                                                  /* compute ambient */
462          i = doambient(acol, r, amb.weight, uvw, amb.rad, amb.gpos, amb.gdir);
463          scalecolor(acol, 1./AVGREFL);           /* undo assumed reflectance */
464 <        if (i <= 0)                             /* no Hessian => no storage */
464 >        if (i <= 0 || amb.rad[0] <= FTINY)      /* no Hessian or zero radius */
465                  return(i);
466                                                  /* store value */
467          VCOPY(amb.pos, r->rop);
# Line 529 | Line 534 | avinsert(                              /* insert ambient value in our tree */
534          at = &atrunk;
535          VCOPY(ck0, thescene.cuorg);
536          s = thescene.cusize;
537 <        while (s*(OCTSCALE/2) > av->rad[1]*ambacc) {
537 >        while (s*(OCTSCALE/2) > av->rad[1]*qambacc) {
538                  if (at->kid == NULL)
539                          if ((at->kid = newambtree()) == NULL)
540                                  error(SYSTEM, "out of memory in avinsert");

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines