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.62 by greg, Mon May 19 20:23:48 2014 UTC vs.
Revision 2.71 by greg, Tue Mar 15 20:35:41 2016 UTC

# Line 21 | Line 21 | static const char      RCSid[] = "$Id$";
21   #include  "ambient.h"
22   #include  "random.h"
23  
24 < #ifdef NEWAMB
24 > #ifndef OLDAMB
25  
26   extern void             SDsquare2disk(double ds[2], double seedx, double seedy);
27  
# Line 78 | Line 78 | ambsample(                             /* initial ambient division sample */
78          hlist[1] = j;
79          hlist[2] = i;
80          multisamp(spt, 2, urand(ilhash(hlist,3)+n));
81 <        if (!n) {                       /* avoid border samples for n==0 */
81 >                                        /* avoid coincident samples */
82 >        if (!n && (0 < i) & (i < hp->ns-1) &&
83 >                        (0 < j) & (j < hp->ns-1)) {
84                  if ((spt[0] < 0.1) | (spt[0] >= 0.9))
85                          spt[0] = 0.1 + 0.8*frandom();
86                  if ((spt[1] < 0.1) | (spt[1] >= 0.9))
# Line 178 | Line 180 | ambsupersamp(AMBHEMI *hp, int cnt)
180          float   *earr = getambdiffs(hp);
181          double  e2rem = 0;
182          AMBSAMP *ap;
181        RAY     ar;
183          float   *ep;
184          int     i, j, n, nss;
185  
# Line 234 | Line 235 | samp_hemi(                             /* sample indirect hemisphere */
235          d = 1.0/(n*n);
236          scalecolor(hp->acoef, d);
237                                          /* make tangent plane axes */
238 <        hp->uy[0] = 0.5 - frandom();
238 <        hp->uy[1] = 0.5 - frandom();
239 <        hp->uy[2] = 0.5 - frandom();
240 <        for (i = 3; i--; )
241 <                if ((-0.6 < r->ron[i]) & (r->ron[i] < 0.6))
242 <                        break;
243 <        if (i < 0)
238 >        if (!getperpendicular(hp->ux, r->ron, 1))
239                  error(CONSISTENCY, "bad ray direction in samp_hemi");
245        hp->uy[i] = 1.0;
246        VCROSS(hp->ux, hp->uy, r->ron);
247        normalize(hp->ux);
240          VCROSS(hp->uy, r->ron, hp->ux);
241                                          /* sample divisions */
242          for (i = hp->ns; i--; )
# Line 608 | Line 600 | static uint32
600   ambcorral(AMBHEMI *hp, FVECT uv[2], const double r0, const double r1)
601   {
602          const double    max_d = 1.0/(minarad*ambacc + 0.001);
603 <        const double    ang_res = 0.5*PI/(hp->ns-1);
604 <        const double    ang_step = ang_res/((int)(16/PI*ang_res) + (1+FTINY));
603 >        const double    ang_res = 0.5*PI/hp->ns;
604 >        const double    ang_step = ang_res/((int)(16/PI*ang_res) + 1.01);
605          double          avg_d = 0;
606          uint32          flgs = 0;
607          FVECT           vec;
# Line 640 | Line 632 | ambcorral(AMBHEMI *hp, FVECT uv[2], const double r0, c
632                  if ((r0*r0*u*u + r1*r1*v*v) * ap->d*ap->d <= u*u + v*v)
633                          continue;       /* occluder outside ellipse */
634                  ang = atan2a(v, u);     /* else set direction flags */
635 <                for (a1 = ang-.5*ang_res; a1 <= ang+.5*ang_res; a1 += ang_step)
635 >                for (a1 = ang-ang_res; a1 <= ang+ang_res; a1 += ang_step)
636                          flgs |= 1L<<(int)(16/PI*(a1 + 2.*PI*(a1 < 0)));
637              }
638                                          /* add low-angle incident (< 20deg) */
# Line 693 | Line 685 | doambient(                             /* compute ambient component */
685                  return(0);
686  
687          if ((ra == NULL) & (pg == NULL) & (dg == NULL) ||
688 <                        (hp->sampOK < 0) | (hp->ns < 4)) {
688 >                        (hp->sampOK < 0) | (hp->ns < 6)) {
689                  free(hp);               /* Hessian not requested/possible */
690                  return(-1);             /* value-only return value */
691          }
# Line 741 | Line 733 | doambient(                             /* compute ambient component */
733                                  ra[0] = maxarad;
734                  }
735                                          /* flag encroached directions */
736 <                if ((wt >= 0.89*AVGREFL) & (crlp != NULL))
736 >                if (crlp != NULL)
737                          *crlp = ambcorral(hp, uv, ra[0]*ambacc, ra[1]*ambacc);
738                  if (pg != NULL) {       /* cap gradient if necessary */
739                          d = pg[0]*pg[0]*ra[0]*ra[0] + pg[1]*pg[1]*ra[1]*ra[1];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines