ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/normal.c
(Generate patch)

Comparing ray/src/rt/normal.c (file contents):
Revision 2.18 by greg, Fri May 15 13:07:55 1992 UTC vs.
Revision 2.24 by greg, Mon Mar 8 12:37:27 1993 UTC

# Line 23 | Line 23 | static char SCCSid[] = "$SunId$ LBL";
23   extern double  specthresh;              /* specular sampling threshold */
24   extern double  specjitter;              /* specular sampling jitter */
25  
26 + static  gaussamp();
27 +
28   /*
29 < *      This routine uses portions of the reflection
30 < *  model described by Cook and Torrance.
29 < *      The computation of specular components has been simplified by
30 < *  numerous approximations and ommisions to improve speed.
29 > *      This routine implements the isotropic Gaussian
30 > *  model described by Ward in Siggraph `92 article.
31   *      We orient the surface towards the incoming ray, so a single
32   *  surface can be used to represent an infinitely thin object.
33   *
# Line 104 | Line 104 | double  omega;                 /* light source size */
104                                                  /* + source if flat */
105                  if (np->specfl & SP_FLAT)
106                          dtmp += omega/(4.0*PI);
107 <                                                /* delta */
107 >                                                /* half vector */
108                  vtmp[0] = ldir[0] - np->rp->rdir[0];
109                  vtmp[1] = ldir[1] - np->rp->rdir[1];
110                  vtmp[2] = ldir[2] - np->rp->rdir[2];
111                  d2 = DOT(vtmp, np->pnorm);
112 <                d2 = 2.0 - 2.0*d2/sqrt(DOT(vtmp,vtmp));
112 >                d2 *= d2;
113 >                d2 = (DOT(vtmp,vtmp) - d2) / d2;
114                                                  /* gaussian */
115                  dtmp = exp(-d2/dtmp)/(4.*PI*dtmp);
116                                                  /* worth using? */
# Line 135 | Line 136 | double  omega;                 /* light source size */
136                   *  is always modified by material color.
137                   */
138                                                  /* roughness + source */
139 <                dtmp = np->alpha2/4.0 + omega/PI;
139 >                dtmp = np->alpha2 + omega/PI;
140                                                  /* gaussian */
141 <                dtmp = exp((2.*DOT(np->prdir,ldir)-2.)/dtmp)/(4.*PI*dtmp);
141 >                dtmp = exp((2.*DOT(np->prdir,ldir)-2.)/dtmp)/(PI*dtmp);
142                                                  /* worth using? */
143                  if (dtmp > FTINY) {
144                          copycolor(ctmp, np->mcolor);
# Line 240 | Line 241 | register RAY  *r;
241                                  transtest = 2;
242                          } else {
243                                  for (i = 0; i < 3; i++)         /* perturb */
244 <                                        nd.prdir[i] = r->rdir[i] -
244 <                                                        0.5*r->pert[i];
244 >                                        nd.prdir[i] = r->rdir[i] - r->pert[i];
245                                  if (DOT(nd.prdir, r->ron) < -FTINY)
246                                          normalize(nd.prdir);    /* OK */
247                                  else
# Line 370 | Line 370 | register NORMDAT  *np;
370                  if (rv[1] <= FTINY)
371                          d = 1.0;
372                  else
373 <                        d = sqrt( np->alpha2/4.0 * -log(rv[1]) );
373 >                        d = sqrt( -log(rv[1]) * np->alpha2 );
374                  for (i = 0; i < 3; i++)
375                          sr.rdir[i] = np->prdir[i] + d*(cosp*u[i] + sinp*v[i]);
376                  if (DOT(sr.rdir, r->ron) < -FTINY)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines