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 |
|
* |
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) { |
157 |
|
dtmp = 1.0 - dtmp1*dtmp1/dtmp; |
158 |
|
if (dtmp > FTINY*FTINY) { |
159 |
|
dtmp1 = DOT(h,np->u); |
160 |
< |
dtmp1 = dtmp1*dtmp1 / au2; |
160 |
> |
dtmp1 *= dtmp1 / au2; |
161 |
|
dtmp2 = DOT(h,np->v); |
162 |
< |
dtmp2 = dtmp2*dtmp2 / av2; |
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) { |