--- ray/src/rt/normal.c 2005/12/08 17:56:38 2.51 +++ ray/src/rt/normal.c 2010/09/26 15:51:15 2.53 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: normal.c,v 2.51 2005/12/08 17:56:38 greg Exp $"; +static const char RCSid[] = "$Id: normal.c,v 2.53 2010/09/26 15:51:15 greg Exp $"; #endif /* * normal.c - shading function for normal materials. @@ -156,12 +156,11 @@ dirnorm( /* compute source contribution */ /* roughness + source */ dtmp = np->alpha2 + omega*(1.0/PI); /* gaussian */ - dtmp = exp((2.*DOT(np->prdir,ldir)-2.)/dtmp) / - (PI*np->pdot*dtmp); + dtmp = exp((2.*DOT(np->prdir,ldir)-2.)/dtmp)/(PI*dtmp); /* worth using? */ if (dtmp > FTINY) { copycolor(ctmp, np->mcolor); - dtmp *= np->tspec * omega; + dtmp *= np->tspec * omega * sqrt(-ldot/np->pdot); scalecolor(ctmp, dtmp); addcolor(cval, ctmp); } @@ -300,6 +299,7 @@ m_normal( /* color a ray that hit something normal * if (hastexture && DOT(nd.vrefl, r->ron) <= FTINY) for (i = 0; i < 3; i++) /* safety measure */ nd.vrefl[i] = r->rdir[i] + 2.*r->rod*r->ron[i]; + checknorm(nd.vrefl); } /* reflected ray */ if ((nd.specfl&(SP_REFL|SP_PURE|SP_RBLT)) == (SP_REFL|SP_PURE)) {