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

Comparing ray/src/rt/aniso.c (file contents):
Revision 2.18 by greg, Tue May 19 17:09:06 1992 UTC vs.
Revision 2.24 by greg, Mon Mar 8 12:37:18 1993 UTC

# Line 19 | Line 19 | static char SCCSid[] = "$SunId$ LBL";
19   extern double  specthresh;              /* specular sampling threshold */
20   extern double  specjitter;              /* specular sampling jitter */
21  
22 + static  agaussamp();
23 +
24   /*
25 < *      This anisotropic reflection model uses a variant on the
26 < *  exponential Gaussian used in normal.c.
25 > *      This routine implements the anisotropic Gaussian
26 > *  model described by Ward in Siggraph `92 article.
27   *      We orient the surface towards the incoming ray, so a single
28   *  surface can be used to represent an infinitely thin object.
29   *
# Line 109 | Line 111 | double  omega;                 /* light source size */
111                  h[0] = ldir[0] - np->rp->rdir[0];
112                  h[1] = ldir[1] - np->rp->rdir[1];
113                  h[2] = ldir[2] - np->rp->rdir[2];
112                normalize(h);
114                                                  /* ellipse */
115                  dtmp1 = DOT(np->u, h);
116                  dtmp1 *= dtmp1 / au2;
117                  dtmp2 = DOT(np->v, h);
118                  dtmp2 *= dtmp2 / av2;
119                                                  /* gaussian */
120 <                dtmp = (dtmp1 + dtmp2) / (1.0 + DOT(np->pnorm, h));
121 <                dtmp = exp(-2.0*dtmp) * 1.0/(4.0*PI)
120 >                dtmp = DOT(np->pnorm, h);
121 >                dtmp = (dtmp1 + dtmp2) / (dtmp*dtmp);
122 >                dtmp = exp(-dtmp) * (0.25/PI)
123                                  * sqrt(ldot/(np->pdot*au2*av2));
124                                                  /* worth using? */
125                  if (dtmp > FTINY) {
# Line 149 | Line 151 | double  omega;                 /* light source size */
151                  h[0] = ldir[0] - np->prdir[0];
152                  h[1] = ldir[1] - np->prdir[1];
153                  h[2] = ldir[2] - np->prdir[2];
154 <                dtmp = DOT(h,np->pnorm);
153 <                dtmp = DOT(h,h) - dtmp*dtmp;
154 >                dtmp = DOT(h,h);
155                  if (dtmp > FTINY*FTINY) {
156 <                        dtmp1 = DOT(h,np->u);
157 <                        dtmp1 = dtmp1*dtmp1 / (au2*dtmp);
158 <                        dtmp2 = DOT(h,np->v);
159 <                        dtmp2 = dtmp2*dtmp2 / (av2*dtmp);
160 <                        dtmp = 2. - 2.*DOT(ldir,np->prdir);
161 <                        dtmp *= dtmp1 + dtmp2;
156 >                        dtmp1 = DOT(h,np->pnorm);
157 >                        dtmp = 1.0 - dtmp1*dtmp1/dtmp;
158 >                        if (dtmp > FTINY*FTINY) {
159 >                                dtmp1 = DOT(h,np->u);
160 >                                dtmp1 *= dtmp1 / au2;
161 >                                dtmp2 = DOT(h,np->v);
162 >                                dtmp2 *= dtmp2 / av2;
163 >                                dtmp = (dtmp1 + dtmp2) / dtmp;
164 >                        }
165                  } else
166                          dtmp = 0.0;
167                                                  /* gaussian */
168 <                dtmp = exp(-dtmp) * 1.0/(4.0*PI)
168 >                dtmp = exp(-dtmp) * (1.0/PI)
169                                  * sqrt(-ldot/(np->pdot*au2*av2));
170                                                  /* worth using? */
171                  if (dtmp > FTINY) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines