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.57 by greg, Fri Nov 5 17:36:55 2004 UTC vs.
Revision 2.58 by greg, Tue Apr 19 01:15:06 2005 UTC

# Line 254 | Line 254 | ambnotify(                     /* record new modifier */
254  
255  
256   extern void
257 < ambient(                /* compute ambient component for ray */
258 <        COLOR  acol,
257 > multambient(            /* compute ambient component & multiply by coef. */
258 >        COLOR  aval,
259          register RAY  *r,
260          FVECT  nrm
261   )
262   {
263          static int  rdepth = 0;                 /* ambient recursion */
264 +        COLOR   acol;
265          double  d, l;
266  
267          if (ambdiv <= 0)                        /* no ambient calculation */
# Line 275 | Line 276 | ambient(               /* compute ambient component for ray */
276  
277          if (ambacc <= FTINY) {                  /* no ambient storage */
278                  rdepth++;
279 <                d = doambient(acol, r, r->rweight, NULL, NULL);
279 >                d = doambient(acol, r, aval, intens(aval)*r->rweight,
280 >                                                        NULL, NULL);
281                  rdepth--;
282                  if (d <= FTINY)
283                          goto dumbamb;
284 +                multcolor(aval, acol);
285                  return;
286          }
287  
# Line 290 | Line 293 | ambient(               /* compute ambient component for ray */
293                          &atrunk, thescene.cuorg, thescene.cusize);
294          if (d > FTINY) {
295                  scalecolor(acol, 1.0/d);
296 +                multcolor(aval, acol);
297                  return;
298          }
299          rdepth++;                               /* need to cache new value */
300 <        d = makeambient(acol, r, nrm, rdepth-1);
300 >        d = makeambient(acol, r, aval, nrm, rdepth-1);
301          rdepth--;
302 <        if (d > FTINY)
302 >        if (d > FTINY) {
303 >                multcolor(aval, acol);          /* got new value */
304                  return;
305 +        }
306   dumbamb:                                        /* return global value */
307 <        copycolor(acol, ambval);
308 <        if ((ambvwt <= 0) | (navsum == 0))
307 >        if ((ambvwt <= 0) | (navsum == 0)) {
308 >                multcolor(aval, ambval);
309                  return;
310 +        }
311          l = bright(ambval);                     /* average in computations */
312          if (l > FTINY) {
313                  d = (log(l)*(double)ambvwt + avsum) /
314                                  (double)(ambvwt + navsum);
315                  d = exp(d) / l;
316 <                scalecolor(acol, d);            /* apply color of ambval */
316 >                scalecolor(aval, d);
317 >                multcolor(aval, ambval);        /* apply color of ambval */
318          } else {
319                  d = exp( avsum / (double)navsum );
320 <                setcolor(acol, d, d, d);        /* neutral color */
320 >                scalecolor(aval, d);            /* neutral color */
321          }
322   }
323  
# Line 431 | Line 439 | sumambient(    /* get interpolated ambient value */
439   extern double
440   makeambient(    /* make a new ambient value */
441          COLOR  acol,
442 <        register RAY  *r,
442 >        RAY  *r,
443 >        COLOR  ac,
444          FVECT  rn,
445          int  al
446   )
447   {
448          AMBVAL  amb;
449 +        double  coef;
450          FVECT   gp, gd;
451                                                  /* compute weight */
452          amb.weight = pow(AVGREFL, (double)al);
453 <        if (r->rweight < 0.1*amb.weight)        /* heuristic */
454 <                amb.weight = r->rweight;
453 >        coef = intens(ac)*r->rweight;
454 >        if (coef < 0.1*amb.weight)              /* heuristic */
455 >                amb.weight = coef;
456                                                  /* compute ambient */
457 <        amb.rad = doambient(acol, r, amb.weight, gp, gd);
457 >        amb.rad = doambient(acol, r, ac, amb.weight, gp, gd);
458          if (amb.rad <= FTINY)
459                  return(0.0);
460                                                  /* store it */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines