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.110 by greg, Fri Feb 19 22:05:46 2021 UTC vs.
Revision 2.111 by greg, Thu Nov 18 19:38:21 2021 UTC

# Line 272 | Line 272 | multambient(           /* compute ambient component & multiply
272          FVECT  nrm
273   )
274   {
275 +        static double  logAvgAbsorp = 1;
276          static int  rdepth = 0;                 /* ambient recursion */
277          COLOR   acol, caustic;
278          int     i, ok;
# Line 283 | Line 284 | multambient(           /* compute ambient component & multiply
284          if (ambPmap(aval, r, rdepth))
285                  return;
286  
287 +        if (logAvgAbsorp > 0)                   /* exclude in -aw to avoid growth */
288 +                logAvgAbsorp = log(1.-AVGREFL);
289 +
290          /* PMAP: Factor in specular-diffuse ambient (caustics) from photon
291           * map, if enabled and ray is primary, else caustic is zero.  Continue
292           * with RADIANCE ambient calculation */
# Line 368 | Line 372 | dumbamb:                                       /* return global value */
372          
373          l = bright(ambval);                     /* average in computations */  
374          if (l > FTINY) {
375 <                d = (log(l)*(double)ambvwt + avsum) /
375 >                d = (log(l)*(double)ambvwt + avsum + logAvgAbsorp*navsum) /
376                                  (double)(ambvwt + navsum);
377                  d = exp(d) / l;
378                  scalecolor(aval, d);
379                  multcolor(aval, ambval);        /* apply color of ambval */
380          } else {
381 <                d = exp( avsum / (double)navsum );
381 >                d = exp( avsum/(double)navsum + logAvgAbsorp );
382                  scalecolor(aval, d);            /* neutral color */
383          }
384   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines