74 |
|
double ldot; |
75 |
|
double dtmp, d2; |
76 |
|
FVECT vtmp; |
77 |
– |
register int i; |
77 |
|
COLOR ctmp; |
78 |
|
|
79 |
|
setcolor(cval, 0.0, 0.0, 0.0); |
105 |
|
if (np->specfl & SP_FLAT) |
106 |
|
dtmp += omega/(4.0*PI); |
107 |
|
/* delta */ |
108 |
< |
for (i = 0; i < 3; i++) |
109 |
< |
vtmp[i] = ldir[i] - np->rp->rdir[i]; |
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)); |
113 |
|
/* gaussian */ |
135 |
|
* is always modified by material color. |
136 |
|
*/ |
137 |
|
/* roughness + source */ |
138 |
< |
dtmp = np->alpha2/2.0 + omega/(2.0*PI); |
138 |
> |
dtmp = np->alpha2 + omega/PI; |
139 |
|
/* gaussian */ |
140 |
< |
dtmp = exp((DOT(np->prdir,ldir)-1.)/dtmp)/(2.*PI)/dtmp; |
140 |
> |
dtmp = exp((2.*DOT(np->prdir,ldir)-2.)/dtmp)/(4.*PI*dtmp); |
141 |
|
/* worth using? */ |
142 |
|
if (dtmp > FTINY) { |
143 |
|
copycolor(ctmp, np->mcolor); |
144 |
< |
dtmp *= np->tspec * omega * sqrt(ldot/np->pdot); |
144 |
> |
dtmp *= np->tspec * omega * sqrt(-ldot/np->pdot); |
145 |
|
scalecolor(ctmp, dtmp); |
146 |
|
addcolor(cval, ctmp); |
147 |
|
} |
240 |
|
transtest = 2; |
241 |
|
} else { |
242 |
|
for (i = 0; i < 3; i++) /* perturb */ |
243 |
< |
nd.prdir[i] = r->rdir[i] - |
244 |
< |
0.5*r->pert[i]; |
243 |
> |
nd.prdir[i] = r->rdir[i] - r->pert[i]; |
244 |
|
if (DOT(nd.prdir, r->ron) < -FTINY) |
245 |
|
normalize(nd.prdir); /* OK */ |
246 |
|
else |
369 |
|
if (rv[1] <= FTINY) |
370 |
|
d = 1.0; |
371 |
|
else |
372 |
< |
d = sqrt( np->alpha2/4.0 * -log(rv[1]) ); |
372 |
> |
d = sqrt( -log(rv[1]) * np->alpha2 ); |
373 |
|
for (i = 0; i < 3; i++) |
374 |
|
sr.rdir[i] = np->prdir[i] + d*(cosp*u[i] + sinp*v[i]); |
375 |
|
if (DOT(sr.rdir, r->ron) < -FTINY) |