--- ray/src/rt/normal.c 1992/05/15 13:07:55 2.18 +++ ray/src/rt/normal.c 1993/03/08 12:37:27 2.24 @@ -23,11 +23,11 @@ static char SCCSid[] = "$SunId$ LBL"; extern double specthresh; /* specular sampling threshold */ extern double specjitter; /* specular sampling jitter */ +static gaussamp(); + /* - * This routine uses portions of the reflection - * model described by Cook and Torrance. - * The computation of specular components has been simplified by - * numerous approximations and ommisions to improve speed. + * This routine implements the isotropic Gaussian + * model described by Ward in Siggraph `92 article. * We orient the surface towards the incoming ray, so a single * surface can be used to represent an infinitely thin object. * @@ -104,12 +104,13 @@ double omega; /* light source size */ /* + source if flat */ if (np->specfl & SP_FLAT) dtmp += omega/(4.0*PI); - /* delta */ + /* half vector */ vtmp[0] = ldir[0] - np->rp->rdir[0]; vtmp[1] = ldir[1] - np->rp->rdir[1]; vtmp[2] = ldir[2] - np->rp->rdir[2]; d2 = DOT(vtmp, np->pnorm); - d2 = 2.0 - 2.0*d2/sqrt(DOT(vtmp,vtmp)); + d2 *= d2; + d2 = (DOT(vtmp,vtmp) - d2) / d2; /* gaussian */ dtmp = exp(-d2/dtmp)/(4.*PI*dtmp); /* worth using? */ @@ -135,9 +136,9 @@ double omega; /* light source size */ * is always modified by material color. */ /* roughness + source */ - dtmp = np->alpha2/4.0 + omega/PI; + dtmp = np->alpha2 + omega/PI; /* gaussian */ - dtmp = exp((2.*DOT(np->prdir,ldir)-2.)/dtmp)/(4.*PI*dtmp); + dtmp = exp((2.*DOT(np->prdir,ldir)-2.)/dtmp)/(PI*dtmp); /* worth using? */ if (dtmp > FTINY) { copycolor(ctmp, np->mcolor); @@ -240,8 +241,7 @@ register RAY *r; transtest = 2; } else { for (i = 0; i < 3; i++) /* perturb */ - nd.prdir[i] = r->rdir[i] - - 0.5*r->pert[i]; + nd.prdir[i] = r->rdir[i] - r->pert[i]; if (DOT(nd.prdir, r->ron) < -FTINY) normalize(nd.prdir); /* OK */ else @@ -370,7 +370,7 @@ register NORMDAT *np; if (rv[1] <= FTINY) d = 1.0; else - d = sqrt( np->alpha2/4.0 * -log(rv[1]) ); + d = sqrt( -log(rv[1]) * np->alpha2 ); for (i = 0; i < 3; i++) sr.rdir[i] = np->prdir[i] + d*(cosp*u[i] + sinp*v[i]); if (DOT(sr.rdir, r->ron) < -FTINY)