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.2 by greg, Wed Feb 19 12:00:04 1992 UTC vs.
Revision 2.6 by greg, Tue Apr 23 11:06:54 1996 UTC

# Line 27 | Line 27 | typedef struct {
27          short  nt, np;          /* number of theta and phi directions */
28   }  AMBHEMI;             /* ambient sample hemisphere */
29  
30 extern double  sin(), cos(), sqrt();
30  
32
31   static int
32   ambcmp(d1, d2)                          /* decreasing order */
33   AMBSAMP  *d1, *d2;
# Line 141 | Line 139 | FVECT  pg, dg;
139                          dp->n = 0;
140                          if (divsample(dp, &hemi, r) < 0)
141                                  goto oopsy;
142 +                        arad += dp->r;
143                          if (div != NULL)
144                                  dp++;
145 <                        else {
145 >                        else
146                                  addcolor(acol, dp->v);
148                                arad += dp->r;
149                        }
147                  }
148 <        if (ns > 0) {                   /* perform super-sampling */
148 >        if (ns > 0 && arad > FTINY && ndivs/arad < minarad)
149 >                ns = 0;                 /* close enough */
150 >        else if (ns > 0) {              /* else perform super-sampling */
151                  comperrs(div, &hemi);                   /* compute errors */
152                  qsort(div, ndivs, sizeof(AMBSAMP), ambcmp);     /* sort divs */
153                                                  /* super-sample */
# Line 170 | Line 169 | FVECT  pg, dg;
169          }
170                                          /* compute returned values */
171          if (div != NULL) {
172 +                arad = 0.0;
173                  for (i = ndivs, dp = div; i-- > 0; dp++) {
174                          arad += dp->r;
175                          if (dp->n > 1) {
# Line 207 | Line 207 | FVECT  pg, dg;
207          scalecolor(acol, b);
208          if (arad <= FTINY)
209                  arad = maxarad;
210 <        else {
210 >        else
211                  arad = (ndivs+ns)/arad;
212                if (arad > maxarad)
213                        arad = maxarad;
214        }
212          if (pg != NULL) {               /* reduce radius if gradient large */
213                  d = DOT(pg,pg);
214                  if (d*arad*arad > 1.0)
# Line 225 | Line 222 | FVECT  pg, dg;
222                                  pg[i] *= d;
223                  }
224          }
225 <        return(arad/sqrt(wt));
225 >        if ((arad /= sqrt(wt)) > maxarad)
226 >                arad = maxarad;
227 >        return(arad);
228   oopsy:
229          if (div != NULL)
230                  free((char *)div);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines