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

Comparing ray/src/rt/ambcomp.c (file contents):
Revision 2.16 by greg, Tue May 31 18:01:09 2005 UTC vs.
Revision 2.17 by greg, Sat Jun 4 06:10:12 2005 UTC

# Line 77 | Line 77 | divsample(                             /* sample a division */
77                  copycolor(ar.rcoef, h->acoef);
78          if (rayorigin(&ar, AMBIENT, r, ar.rcoef) < 0)
79                  return(-1);
80 <        if (ambacc > FTINY)
81 <                copycolor(ar.rcoef, h->acoef);
80 >        if (ambacc > FTINY) {
81 >                multcolor(ar.rcoef, h->acoef);
82 >                scalecolor(ar.rcoef, 1./AVGREFL);
83 >        }
84          hlist[0] = r->rno;
85          hlist[1] = dp->t;
86          hlist[2] = dp->p;
# Line 164 | Line 166 | doambient(                             /* compute ambient component */
166                                          /* initialize hemisphere */
167          inithemi(&hemi, acol, r, wt);
168          ndivs = hemi.nt * hemi.np;
169 <                                        /* initialize sum */
169 >                                        /* initialize */
170 >        if (pg != NULL)
171 >                pg[0] = pg[1] = pg[2] = 0.0;
172 >        if (dg != NULL)
173 >                dg[0] = dg[1] = dg[2] = 0.0;
174          setcolor(acol, 0.0, 0.0, 0.0);
175          if (ndivs == 0)
176                  return(0.0);
# Line 187 | Line 193 | doambient(                             /* compute ambient component */
193                          dp->n = 0;
194                          if (divsample(dp, &hemi, r) < 0) {
195                                  if (div != NULL) dp++;
196 +                                hemi.ns = 0;    /* incomplete sampling */
197 +                                pg = dg = NULL;
198                                  continue;
199                          }
200                          arad += dp->r;
# Line 233 | Line 241 | doambient(                             /* compute ambient component */
241                  }
242                  b = bright(acol);
243                  if (b > FTINY) {
244 <                        b = 1.0/b;      /* normalize gradient(s) */
244 >                        b = 1.0/b;      /* compute & normalize gradient(s) */
245                          if (pg != NULL) {
246                                  posgradient(pg, div, &hemi);
247                                  for (i = 0; i < 3; i++)
# Line 244 | Line 252 | doambient(                             /* compute ambient component */
252                                  for (i = 0; i < 3; i++)
253                                          dg[i] *= b;
254                          }
247                } else {
248                        if (pg != NULL)
249                                for (i = 0; i < 3; i++)
250                                        pg[i] = 0.0;
251                        if (dg != NULL)
252                                for (i = 0; i < 3; i++)
253                                        dg[i] = 0.0;
255                  }
256                  free((void *)div);
257          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines