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.76 by greg, Thu Jan 26 16:46:58 2017 UTC vs.
Revision 2.77 by greg, Fri Apr 21 16:07:29 2017 UTC

# Line 160 | Line 160 | resample:
160   static float *
161   getambdiffs(AMBHEMI *hp)
162   {
163 +        const double    normf = 1./bright(hp->acoef);
164          float   *earr = (float *)calloc(hp->ns*hp->ns, sizeof(float));
165          float   *ep;
166          AMBSAMP *ap;
# Line 173 | Line 174 | getambdiffs(AMBHEMI *hp)
174              for (j = 0; j < hp->ns; j++, ap++, ep++) {
175                  b = bright(ap[0].v);
176                  if (i) {                /* from above */
177 <                        d2 = b - bright(ap[-hp->ns].v);
177 >                        d2 = normf*(b - bright(ap[-hp->ns].v));
178                          d2 *= d2;
179                          ep[0] += d2;
180                          ep[-hp->ns] += d2;
181                  }
182                  if (!j) continue;
183                                          /* from behind */
184 <                d2 = b - bright(ap[-1].v);
184 >                d2 = normf*(b - bright(ap[-1].v));
185                  d2 *= d2;
186                  ep[0] += d2;
187                  ep[-1] += d2;
188                  if (!i) continue;
189                                          /* diagonal */
190 <                d2 = b - bright(ap[-hp->ns-1].v);
190 >                d2 = normf*(b - bright(ap[-hp->ns-1].v));
191                  d2 *= d2;
192                  ep[0] += d2;
193                  ep[-hp->ns-1] += d2;
# Line 230 | Line 231 | ambsupersamp(AMBHEMI *hp, int cnt)
231                          goto done;      /* nothing left to do */
232                  nss = *ep/e2rem*cnt + frandom();
233                  for (n = 1; n <= nss && ambsample(hp,i,j,n); n++)
234 <                        --cnt;
234 >                        if (!--cnt) goto done;
235                  e2rem -= *ep++;         /* update remainder */
236          }
237   done:
# Line 248 | Line 249 | samp_hemi(                             /* sample indirect hemisphere */
249          AMBHEMI *hp;
250          double  d;
251          int     n, i, j;
252 +                                        /* insignificance check */
253 +        if (bright(rcol) <= FTINY)
254 +                return(NULL);
255                                          /* set number of divisions */
256          if (ambacc <= FTINY &&
257                          wt > (d = 0.8*intens(rcol)*r->rweight/(ambdiv*minweight)))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines