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.58 by greg, Tue Apr 19 01:15:06 2005 UTC vs.
Revision 2.60 by greg, Sat May 28 22:27:54 2005 UTC

# Line 289 | Line 289 | multambient(           /* compute ambient component & multiply
289                  sortambvals(0);
290                                                  /* get ambient value */
291          setcolor(acol, 0.0, 0.0, 0.0);
292 <        d = sumambient(acol, r, nrm, rdepth,
292 >        d = sumambient(acol, r, intens(aval)*r->rweight, nrm, rdepth,
293                          &atrunk, thescene.cuorg, thescene.cusize);
294          if (d > FTINY) {
295                  scalecolor(acol, 1.0/d);
# Line 326 | Line 326 | extern double
326   sumambient(     /* get interpolated ambient value */
327          COLOR  acol,
328          register RAY  *r,
329 +        double  aw,
330          FVECT  rn,
331          int  al,
332          AMBTREE  *at,
# Line 351 | Line 352 | sumambient(    /* get interpolated ambient value */
352                   */
353                  if (av->lvl > al)       /* list sorted, so this works */
354                          break;
355 <                if (av->weight < r->rweight-FTINY)
355 >                if (av->weight < 0.85*aw)
356                          continue;
357                  /*
358                   *  Ambient radius test.
# Line 430 | Line 431 | sumambient(    /* get interpolated ambient value */
431                                  break;
432                  }
433                  if (j == 3)
434 <                        wsum += sumambient(acol, r, rn, al, at->kid+i, ck0, s);
434 >                        wsum += sumambient(acol, r, aw, rn, al,
435 >                                                at->kid+i, ck0, s);
436          }
437          return(wsum);
438   }
439  
440  
441   extern double
442 < makeambient(    /* make a new ambient value */
442 > makeambient(            /* make a new ambient value */
443          COLOR  acol,
444          RAY  *r,
445          COLOR  ac,
# Line 446 | Line 448 | makeambient(   /* make a new ambient value */
448   )
449   {
450          AMBVAL  amb;
451 <        double  coef;
451 >        double  awt;
452          FVECT   gp, gd;
453 <                                                /* compute weight */
454 <        amb.weight = pow(AVGREFL, (double)al);
455 <        coef = intens(ac)*r->rweight;
456 <        if (coef < 0.1*amb.weight)              /* heuristic */
457 <                amb.weight = coef;
453 >        int     i;
454 >
455 >        amb.weight = AVGREFL;                   /* compute weight */
456 >        for (i = al; i-- >= 0; )
457 >                amb.weight *= AVGREFL;
458 >        awt = intens(ac)*r->rweight;
459 >        if (awt < 0.07*amb.weight)              /* heuristic override */
460 >                amb.weight = 1.2*awt;
461                                                  /* compute ambient */
462          amb.rad = doambient(acol, r, ac, amb.weight, gp, gd);
463          if (amb.rad <= FTINY)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines