--- ray/src/rt/aniso.c 2010/10/08 22:08:26 2.47 +++ ray/src/rt/aniso.c 2010/10/10 19:49:17 2.48 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: aniso.c,v 2.47 2010/10/08 22:08:26 greg Exp $"; +static const char RCSid[] = "$Id: aniso.c,v 2.48 2010/10/10 19:49:17 greg Exp $"; #endif /* * Shading functions for anisotropic materials. @@ -357,12 +357,13 @@ agaussamp( /* sample anisotropic Gaussian specular */ copycolor(scol, np->scolor); ns2go = 1; if (specjitter > 1.5) { /* multiple samples? */ - ns2go = specjitter*r->rweight + .5; - if ((d = bright(scol)) <= minweight*ns2go) - ns2go = d/minweight; + ns2go = specjitter*sr.rweight + .5; + if (sr.rweight <= minweight*ns2go) + ns2go = sr.rweight/minweight; if (ns2go > 1) { d = 1./ns2go; scalecolor(scol, d); + sr.rweight *= d; } else ns2go = 1; } @@ -398,8 +399,8 @@ agaussamp( /* sample anisotropic Gaussian specular */ continue; checknorm(sr.rdir); if (specjitter > 1.5) { /* adjusted W-G-M-D weight */ - copycolor(sr.rcoef, scol); d = 2.*(1. - np->pdot/d); + copycolor(sr.rcoef, scol); scalecolor(sr.rcoef, d); rayclear(&sr); } @@ -415,15 +416,15 @@ agaussamp( /* sample anisotropic Gaussian specular */ scalecolor(sr.rcoef, np->tspec); if ((np->specfl & (SP_TRAN|SP_TBLT)) == SP_TRAN && rayorigin(&sr, SPECULAR, r, sr.rcoef) == 0) { - copycolor(scol, sr.rcoef); ns2go = 1; if (specjitter > 1.5) { /* multiple samples? */ - ns2go = specjitter*r->rweight + .5; - if ((d = bright(scol)) <= minweight*ns2go) - ns2go = d/minweight; + ns2go = specjitter*sr.rweight + .5; + if (sr.rweight <= minweight*ns2go) + ns2go = sr.rweight/minweight; if (ns2go > 1) { d = 1./ns2go; - scalecolor(scol, d); + scalecolor(sr.rcoef, d); + sr.rweight *= d; } else ns2go = 1; } @@ -454,10 +455,8 @@ agaussamp( /* sample anisotropic Gaussian specular */ if (DOT(sr.rdir, r->ron) >= -FTINY) continue; normalize(sr.rdir); /* OK, normalize */ - if (specjitter > 1.5) { /* multi-sampling */ - copycolor(sr.rcoef, scol); + if (specjitter > 1.5) /* multi-sampling */ rayclear(&sr); - } rayvalue(&sr); multcolor(sr.rcol, sr.rcoef); addcolor(r->rcol, sr.rcol);