--- ray/src/rt/ambcomp.c 2014/08/21 10:33:49 2.65 +++ ray/src/rt/ambcomp.c 2014/10/23 18:19:14 2.68 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: ambcomp.c,v 2.65 2014/08/21 10:33:49 greg Exp $"; +static const char RCSid[] = "$Id: ambcomp.c,v 2.68 2014/10/23 18:19:14 greg Exp $"; #endif /* * Routines to compute "ambient" values using Monte Carlo @@ -180,7 +180,6 @@ ambsupersamp(AMBHEMI *hp, int cnt) float *earr = getambdiffs(hp); double e2rem = 0; AMBSAMP *ap; - RAY ar; float *ep; int i, j, n, nss; @@ -219,7 +218,7 @@ samp_hemi( /* sample indirect hemisphere */ wt > (d = 0.8*intens(rcol)*r->rweight/(ambdiv*minweight))) wt = d; /* avoid ray termination */ n = sqrt(ambdiv * wt) + 0.5; - i = 1 + 8*(ambacc > FTINY); /* minimum number of samples */ + i = 1 + 5*(ambacc > FTINY); /* minimum number of samples */ if (n < i) n = i; /* allocate sampling array */ @@ -610,8 +609,8 @@ static uint32 ambcorral(AMBHEMI *hp, FVECT uv[2], const double r0, const double r1) { const double max_d = 1.0/(minarad*ambacc + 0.001); - const double ang_res = 0.5*PI/(hp->ns-1); - const double ang_step = ang_res/((int)(16/PI*ang_res) + (1+FTINY)); + const double ang_res = 0.5*PI/hp->ns; + const double ang_step = ang_res/((int)(16/PI*ang_res) + 1.01); double avg_d = 0; uint32 flgs = 0; FVECT vec; @@ -642,7 +641,7 @@ ambcorral(AMBHEMI *hp, FVECT uv[2], const double r0, c if ((r0*r0*u*u + r1*r1*v*v) * ap->d*ap->d <= u*u + v*v) continue; /* occluder outside ellipse */ ang = atan2a(v, u); /* else set direction flags */ - for (a1 = ang-.5*ang_res; a1 <= ang+.5*ang_res; a1 += ang_step) + for (a1 = ang-ang_res; a1 <= ang+ang_res; a1 += ang_step) flgs |= 1L<<(int)(16/PI*(a1 + 2.*PI*(a1 < 0))); } /* add low-angle incident (< 20deg) */ @@ -695,7 +694,7 @@ doambient( /* compute ambient component */ return(0); if ((ra == NULL) & (pg == NULL) & (dg == NULL) || - (hp->sampOK < 0) | (hp->ns < 9)) { + (hp->sampOK < 0) | (hp->ns < 6)) { free(hp); /* Hessian not requested/possible */ return(-1); /* value-only return value */ }