--- ray/src/rt/ambient.c 2014/04/19 02:39:44 2.74 +++ ray/src/rt/ambient.c 2014/04/25 18:38:47 2.80 @@ -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.80 2014/04/25 18:38:47 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) { @@ -357,8 +357,10 @@ sumambient( /* get interpolated ambient value */ FVECT c0, double s ) -{ /* initial limit is ambacc radians */ - const double maxangle = (ambacc-PI/2.)*pow(r->rweight,0.13) + PI/2.; +{ /* initial limit is 10 degrees plus ambacc radians */ + const double minangle = 10.0 * PI/180.; + const double maxangle = (minangle+ambacc-PI/2.)*pow(r->rweight,0.13) + + PI/2.; double wsum = 0.0; FVECT ck0; int i, j; @@ -398,22 +400,16 @@ 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) + d = DOT(ck0, uvw[2]) / av->rad[0]; + delta_t2 += d*d; + if (delta_t2 >= qambacc*qambacc) continue; /* - * Intersection behind test - */ - 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) - 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 +457,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);