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.86 by greg, Wed Feb 17 01:29:22 2021 UTC vs.
Revision 2.89 by greg, Tue Apr 19 00:36:34 2022 UTC

# Line 25 | Line 25 | static const char      RCSid[] = "$Id$";
25   #define MINADIV         7       /* minimum # divisions in each dimension */
26   #endif
27  
28 extern void             SDsquare2disk(double ds[2], double seedx, double seedy);
29
28   typedef struct {
29          COLOR   v;              /* hemisphere sample value */
30          float   d;              /* reciprocal distance */
# Line 100 | Line 98 | ambsample(                             /* initial ambient division sample */
98          AMBSAMP *ap = &ambsam(hp,i,j);
99          RAY     ar;
100          int     hlist[3], ii;
101 <        double  spt[2], zd;
101 >        RREAL   spt[2];
102 >        double  zd;
103                                          /* generate hemispherical sample */
104                                          /* ambient coefficient for weight */
105          if (ambacc > FTINY)
# Line 118 | Line 117 | ambsample(                             /* initial ambient division sample */
117          hlist[2] = i;
118          multisamp(spt, 2, urand(ilhash(hlist,3)+n));
119   resample:
120 <        SDsquare2disk(spt, (j+spt[1])/hp->ns, (i+spt[0])/hp->ns);
120 >        square2disk(spt, (j+spt[1])/hp->ns, (i+spt[0])/hp->ns);
121          zd = sqrt(1. - spt[0]*spt[0] - spt[1]*spt[1]);
122          for (ii = 3; ii--; )
123                  ar.rdir[ii] =   spt[0]*hp->ux[ii] +
# Line 179 | Line 178 | getambdiffs(AMBHEMI *hp)
178                  if (i) {                /* from above */
179                          b1 = bright(ap[-hp->ns].v);
180                          d2 = b - b1;
181 <                        d2 *= d2*normf/(b + b1);
181 >                        d2 *= d2*normf/(b + b1 + FTINY);
182                          ep[0] += d2;
183                          ep[-hp->ns] += d2;
184                  }
# Line 187 | Line 186 | getambdiffs(AMBHEMI *hp)
186                                          /* from behind */
187                  b1 = bright(ap[-1].v);
188                  d2 = b - b1;
189 <                d2 *= d2*normf/(b + b1);
189 >                d2 *= d2*normf/(b + b1 + FTINY);
190                  ep[0] += d2;
191                  ep[-1] += d2;
192                  if (!i) continue;
193                                          /* diagonal */
194                  b1 = bright(ap[-hp->ns-1].v);
195                  d2 = b - b1;
196 <                d2 *= d2*normf/(b + b1);
196 >                d2 *= d2*normf/(b + b1 + FTINY);
197                  ep[0] += d2;
198                  ep[-hp->ns-1] += d2;
199              }
# Line 765 | Line 764 | doambient(                             /* compute ambient component */
764                                  ra[0] = maxarad;
765                  }
766                                          /* flag encroached directions */
767 <                if (crlp != NULL)
767 >                if (crlp != NULL)       /* XXX doesn't update with changes to ambacc */
768                          *crlp = ambcorral(hp, uv, ra[0]*ambacc, ra[1]*ambacc);
769                  if (pg != NULL) {       /* cap gradient if necessary */
770                          d = pg[0]*pg[0]*ra[0]*ra[0] + pg[1]*pg[1]*ra[1]*ra[1];
# Line 779 | Line 778 | doambient(                             /* compute ambient component */
778          free(hp);                       /* clean up and return */
779          return(1);
780   }
782

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines