--- ray/src/rt/ambient.c 2005/04/19 01:15:06 2.58 +++ ray/src/rt/ambient.c 2005/05/28 22:27:54 2.60 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: ambient.c,v 2.58 2005/04/19 01:15:06 greg Exp $"; +static const char RCSid[] = "$Id: ambient.c,v 2.60 2005/05/28 22:27:54 greg Exp $"; #endif /* * ambient.c - routines dealing with ambient (inter-reflected) component. @@ -289,7 +289,7 @@ multambient( /* compute ambient component & multiply sortambvals(0); /* get ambient value */ setcolor(acol, 0.0, 0.0, 0.0); - d = sumambient(acol, r, nrm, rdepth, + d = sumambient(acol, r, intens(aval)*r->rweight, nrm, rdepth, &atrunk, thescene.cuorg, thescene.cusize); if (d > FTINY) { scalecolor(acol, 1.0/d); @@ -326,6 +326,7 @@ extern double sumambient( /* get interpolated ambient value */ COLOR acol, register RAY *r, + double aw, FVECT rn, int al, AMBTREE *at, @@ -351,7 +352,7 @@ sumambient( /* get interpolated ambient value */ */ if (av->lvl > al) /* list sorted, so this works */ break; - if (av->weight < r->rweight-FTINY) + if (av->weight < 0.85*aw) continue; /* * Ambient radius test. @@ -430,14 +431,15 @@ sumambient( /* get interpolated ambient value */ break; } if (j == 3) - wsum += sumambient(acol, r, rn, al, at->kid+i, ck0, s); + wsum += sumambient(acol, r, aw, rn, al, + at->kid+i, ck0, s); } return(wsum); } extern double -makeambient( /* make a new ambient value */ +makeambient( /* make a new ambient value */ COLOR acol, RAY *r, COLOR ac, @@ -446,13 +448,16 @@ makeambient( /* make a new ambient value */ ) { AMBVAL amb; - double coef; + double awt; FVECT gp, gd; - /* compute weight */ - amb.weight = pow(AVGREFL, (double)al); - coef = intens(ac)*r->rweight; - if (coef < 0.1*amb.weight) /* heuristic */ - amb.weight = coef; + int i; + + amb.weight = AVGREFL; /* compute weight */ + for (i = al; i-- >= 0; ) + amb.weight *= AVGREFL; + awt = intens(ac)*r->rweight; + if (awt < 0.07*amb.weight) /* heuristic override */ + amb.weight = 1.2*awt; /* compute ambient */ amb.rad = doambient(acol, r, ac, amb.weight, gp, gd); if (amb.rad <= FTINY)