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.94 by greg, Wed Apr 17 17:34:11 2024 UTC vs.
Revision 2.96 by greg, Fri Nov 15 20:47:42 2024 UTC

# Line 112 | Line 112 | ambsample(                             /* initial ambient division sample */
112          if (rayorigin(&ar, hp->atyp, hp->rp, ar.rcoef) < 0)
113                  return(0);
114          if (ambacc > FTINY) {
115 + #ifdef SSKIPOPT
116 +                ar.rsrc = -1;           /* protect cache from source opt. */
117 +                ar.scorr = 1.f;
118 + #endif
119                  smultscolor(ar.rcoef, hp->acoef);
120                  scalescolor(ar.rcoef, 1./AVGREFL);
121          }
# Line 173 | Line 177 | getambdiffs(AMBHEMI *hp)
177          if (earr == NULL)               /* out of memory? */
178                  return(NULL);
179                                          /* sum squared neighbor diffs */
180 <        for (ap = hp->sa, ep = earr, i = 0; i < hp->ns; i++)
180 >        ap = hp->sa;
181 >        ep = earr + hp->ns*hp->ns;      /* original estimates to scratch */
182 >        for (i = 0; i < hp->ns; i++)
183              for (j = 0; j < hp->ns; j++, ap++, ep++) {
184                  b = pbright(ap[0].v);
185                  if (i) {                /* from above */
# Line 199 | Line 205 | getambdiffs(AMBHEMI *hp)
205                  ep[-hp->ns-1] += d2;
206              }
207                                          /* correct for number of neighbors */
208 <        earr[0] *= 6./3.;
209 <        earr[hp->ns-1] *= 6./3.;
210 <        earr[(hp->ns-1)*hp->ns] *= 6./3.;
211 <        earr[(hp->ns-1)*hp->ns + hp->ns-1] *= 6./3.;
208 >        ep = earr + hp->ns*hp->ns;
209 >        ep[0] *= 6./3.;
210 >        ep[hp->ns-1] *= 6./3.;
211 >        ep[(hp->ns-1)*hp->ns] *= 6./3.;
212 >        ep[(hp->ns-1)*hp->ns + hp->ns-1] *= 6./3.;
213          for (i = 1; i < hp->ns-1; i++) {
214 <                earr[i*hp->ns] *= 6./5.;
215 <                earr[i*hp->ns + hp->ns-1] *= 6./5.;
214 >                ep[i*hp->ns] *= 6./5.;
215 >                ep[i*hp->ns + hp->ns-1] *= 6./5.;
216          }
217          for (j = 1; j < hp->ns-1; j++) {
218 <                earr[j] *= 6./5.;
219 <                earr[(hp->ns-1)*hp->ns + j] *= 6./5.;
218 >                ep[j] *= 6./5.;
219 >                ep[(hp->ns-1)*hp->ns + j] *= 6./5.;
220          }
221 <                                        /* blur map to reduce bias */
215 <        memcpy(earr+hp->ns*hp->ns, earr, hp->ns*hp->ns*sizeof(float));
221 >                                        /* blur final map to reduce bias */
222          for (i = 0; i < hp->ns-1; i++) {
223              float  *ep2;
224              ep = earr + i*hp->ns;
225              ep2 = ep + hp->ns*hp->ns;
226              for (j = 0; j < hp->ns-1; j++, ep++, ep2++) {
227 <                ep[0] += .125*(ep2[1] + ep2[hp->ns]) - .5*ep2[0];
227 >                ep[0] += .5*ep2[0] + .125*(ep2[1] + ep2[hp->ns]);
228                  ep[1] += .125*ep2[0];
229                  ep[hp->ns] += .125*ep2[0];
230              }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines