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.19 by greg, Sat May 16 08:37:06 1992 UTC vs.
Revision 2.23 by greg, Fri Feb 12 10:41:02 1993 UTC

# Line 24 | Line 24 | extern double  specthresh;             /* specular sampling thres
24   extern double  specjitter;              /* specular sampling jitter */
25  
26   /*
27 < *      This routine uses portions of the reflection
28 < *  model described by Cook and Torrance.
29 < *      The computation of specular components has been simplified by
30 < *  numerous approximations and ommisions to improve speed.
27 > *      This routine implements the isotropic Gaussian
28 > *  model described by Ward in Siggraph `92 article.
29   *      We orient the surface towards the incoming ray, so a single
30   *  surface can be used to represent an infinitely thin object.
31   *
# Line 104 | Line 102 | double  omega;                 /* light source size */
102                                                  /* + source if flat */
103                  if (np->specfl & SP_FLAT)
104                          dtmp += omega/(4.0*PI);
105 <                                                /* delta */
105 >                                                /* half vector */
106                  vtmp[0] = ldir[0] - np->rp->rdir[0];
107                  vtmp[1] = ldir[1] - np->rp->rdir[1];
108                  vtmp[2] = ldir[2] - np->rp->rdir[2];
109                  d2 = DOT(vtmp, np->pnorm);
110 <                d2 = 2.0 - 2.0*d2/sqrt(DOT(vtmp,vtmp));
110 >                d2 *= d2;
111 >                d2 = (DOT(vtmp,vtmp) - d2) / d2;
112                                                  /* gaussian */
113                  dtmp = exp(-d2/dtmp)/(4.*PI*dtmp);
114                                                  /* worth using? */
# Line 137 | Line 136 | double  omega;                 /* light source size */
136                                                  /* roughness + source */
137                  dtmp = np->alpha2 + omega/PI;
138                                                  /* gaussian */
139 <                dtmp = exp((2.*DOT(np->prdir,ldir)-2.)/dtmp)/(4.*PI*dtmp);
139 >                dtmp = exp((2.*DOT(np->prdir,ldir)-2.)/dtmp)/(PI*dtmp);
140                                                  /* worth using? */
141                  if (dtmp > FTINY) {
142                          copycolor(ctmp, np->mcolor);
# Line 369 | Line 368 | register NORMDAT  *np;
368                  if (rv[1] <= FTINY)
369                          d = 1.0;
370                  else
371 <                        d = sqrt( np->alpha2/4.0 * -log(rv[1]) );
371 >                        d = sqrt( -log(rv[1]) * np->alpha2 );
372                  for (i = 0; i < 3; i++)
373                          sr.rdir[i] = np->prdir[i] + d*(cosp*u[i] + sinp*v[i]);
374                  if (DOT(sr.rdir, r->ron) < -FTINY)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines