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.66 by greg, Thu Sep 4 09:09:08 2014 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 217 | Line 219 | samp_hemi(                             /* sample indirect hemisphere */
219                          wt > (d = 0.8*intens(rcol)*r->rweight/(ambdiv*minweight)))
220                  wt = d;                 /* avoid ray termination */
221          n = sqrt(ambdiv * wt) + 0.5;
222 <        i = 1 + 5*(ambacc > FTINY);     /* minimum number of samples */
222 >        i = 1 + 8*(ambacc > FTINY);     /* minimum number of samples */
223          if (n < i)
224                  n = i;
225                                          /* allocate sampling array */
# Line 608 | Line 610 | static uint32
610   ambcorral(AMBHEMI *hp, FVECT uv[2], const double r0, const double r1)
611   {
612          const double    max_d = 1.0/(minarad*ambacc + 0.001);
613 <        const double    ang_res = 0.5*PI/(hp->ns-1);
614 <        const double    ang_step = ang_res/((int)(16/PI*ang_res) + (1+FTINY));
613 >        const double    ang_res = 0.5*PI/hp->ns;
614 >        const double    ang_step = ang_res/((int)(16/PI*ang_res) + 1.01);
615          double          avg_d = 0;
616          uint32          flgs = 0;
617          FVECT           vec;
# Line 640 | Line 642 | ambcorral(AMBHEMI *hp, FVECT uv[2], const double r0, c
642                  if ((r0*r0*u*u + r1*r1*v*v) * ap->d*ap->d <= u*u + v*v)
643                          continue;       /* occluder outside ellipse */
644                  ang = atan2a(v, u);     /* else set direction flags */
645 <                for (a1 = ang-.5*ang_res; a1 <= ang+.5*ang_res; a1 += ang_step)
645 >                for (a1 = ang-ang_res; a1 <= ang+ang_res; a1 += ang_step)
646                          flgs |= 1L<<(int)(16/PI*(a1 + 2.*PI*(a1 < 0)));
647              }
648                                          /* add low-angle incident (< 20deg) */
# Line 693 | Line 695 | doambient(                             /* compute ambient component */
695                  return(0);
696  
697          if ((ra == NULL) & (pg == NULL) & (dg == NULL) ||
698 <                        (hp->sampOK < 0) | (hp->ns < 4)) {
698 >                        (hp->sampOK < 0) | (hp->ns < 9)) {
699                  free(hp);               /* Hessian not requested/possible */
700                  return(-1);             /* value-only return value */
701          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines