--- ray/src/rt/ambient.c 2014/04/19 02:39:44 2.74 +++ ray/src/rt/ambient.c 2014/04/24 19:16:52 2.78 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: ambient.c,v 2.74 2014/04/19 02:39:44 greg Exp $"; +static const char RCSid[] = "$Id: ambient.c,v 2.78 2014/04/24 19:16:52 greg Exp $"; #endif /* * ambient.c - routines dealing with ambient (inter-reflected) component. @@ -152,7 +152,7 @@ setambient(void) /* initialize calculation */ ambdone(); /* init ambient limits */ setambres(ambres); - setambacc(ambacc); + qambacc = sqrt(sqrt(ambacc *= (ambacc > FTINY))); if (ambfile == NULL || !ambfile[0]) return; if (ambacc <= FTINY) { @@ -398,7 +398,7 @@ sumambient( /* get interpolated ambient value */ delta_t2 = d*d; d = DOT(ck0, uvw[1]) / av->rad[1]; delta_t2 += d*d; - if (delta_t2 >= ambacc*ambacc) + if (delta_t2 >= qambacc*qambacc) continue; /* * Intersection behind test @@ -406,14 +406,14 @@ sumambient( /* get interpolated ambient value */ d = 0.0; for (j = 0; j < 3; j++) d += (r->rop[j] - av->pos[j])*(uvw[2][j] + r->ron[j]); - if (d*0.5 < -minarad*ambacc-.001) + if (d*0.5 < -minarad*qambacc-.001) continue; /* * Extrapolate value and compute final weight (hat function) */ extambient(ct, av, r->rop, rn, uvw); d = tfunc(maxangle, sqrt(delta_r2), 0.0) * - tfunc(ambacc, sqrt(delta_t2), 0.0); + tfunc(qambacc, sqrt(delta_t2), 0.0); scalecolor(ct, d); addcolor(acol, ct); wsum += d; @@ -461,7 +461,7 @@ makeambient( /* make a new ambient value for storage /* compute ambient */ i = doambient(acol, r, amb.weight, uvw, amb.rad, amb.gpos, amb.gdir); scalecolor(acol, 1./AVGREFL); /* undo assumed reflectance */ - if (i <= 0) /* no Hessian => no storage */ + if (i <= 0 || amb.rad[0] <= FTINY) /* no Hessian or zero radius */ return(i); /* store value */ VCOPY(amb.pos, r->rop);