--- ray/src/rt/ambcomp.c 2014/06/19 16:26:55 2.63 +++ ray/src/rt/ambcomp.c 2014/08/21 10:33:49 2.65 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: ambcomp.c,v 2.63 2014/06/19 16:26:55 greg Exp $"; +static const char RCSid[] = "$Id: ambcomp.c,v 2.65 2014/08/21 10:33:49 greg Exp $"; #endif /* * Routines to compute "ambient" values using Monte Carlo @@ -78,7 +78,9 @@ ambsample( /* initial ambient division sample */ hlist[1] = j; hlist[2] = i; multisamp(spt, 2, urand(ilhash(hlist,3)+n)); - if (!n) { /* avoid border samples for n==0 */ + /* avoid coincident samples */ + if (!n && (0 < i) & (i < hp->ns-1) && + (0 < j) & (j < hp->ns-1)) { if ((spt[0] < 0.1) | (spt[0] >= 0.9)) spt[0] = 0.1 + 0.8*frandom(); if ((spt[1] < 0.1) | (spt[1] >= 0.9)) @@ -217,7 +219,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 + 5*(ambacc > FTINY); /* minimum number of samples */ + i = 1 + 8*(ambacc > FTINY); /* minimum number of samples */ if (n < i) n = i; /* allocate sampling array */ @@ -693,7 +695,7 @@ doambient( /* compute ambient component */ return(0); if ((ra == NULL) & (pg == NULL) & (dg == NULL) || - (hp->sampOK < 0) | (hp->ns < 4)) { + (hp->sampOK < 0) | (hp->ns < 9)) { free(hp); /* Hessian not requested/possible */ return(-1); /* value-only return value */ }