| 128 |
|
* is always modified by material color. |
| 129 |
|
*/ |
| 130 |
|
/* roughness + source */ |
| 131 |
< |
dtmp = np->alpha2 + omega/(2.0*PI); |
| 131 |
> |
dtmp = np->alpha2/2.0 + omega/(2.0*PI); |
| 132 |
|
/* gaussian */ |
| 133 |
|
dtmp = exp((DOT(np->prdir,ldir)-1.)/dtmp)/(2.*PI)/dtmp; |
| 134 |
|
/* worth using? */ |
| 194 |
|
/* check threshold */ |
| 195 |
|
if (specthresh > FTINY && |
| 196 |
|
((specthresh >= 1.-FTINY || |
| 197 |
< |
specthresh + (.1 - .2*urand(8199+samplendx)) |
| 197 |
> |
specthresh + (.05 - .1*urand(8199+samplendx)) |
| 198 |
|
> nd.rspec))) |
| 199 |
|
nd.specfl |= SP_RBLT; |
| 200 |
|
/* compute reflected ray */ |
| 225 |
|
if (specthresh > FTINY && |
| 226 |
|
((specthresh >= 1.-FTINY || |
| 227 |
|
specthresh + |
| 228 |
< |
(.1 - .2*urand(7241+samplendx)) |
| 228 |
> |
(.05 - .1*urand(7241+samplendx)) |
| 229 |
|
> nd.tspec))) |
| 230 |
|
nd.specfl |= SP_TBLT; |
| 231 |
|
if (r->crtype & SHADOW || |
| 235 |
|
} else { |
| 236 |
|
for (i = 0; i < 3; i++) /* perturb */ |
| 237 |
|
nd.prdir[i] = r->rdir[i] - |
| 238 |
< |
.75*r->pert[i]; |
| 238 |
> |
0.5*r->pert[i]; |
| 239 |
|
if (DOT(nd.prdir, r->ron) < -FTINY) |
| 240 |
|
normalize(nd.prdir); /* OK */ |
| 241 |
|
else |
| 346 |
|
ndims--; |
| 347 |
|
} |
| 348 |
|
/* compute transmission */ |
| 349 |
+ |
if ((np->specfl & (SP_TRAN|SP_TBLT)) == SP_TRAN && |
| 350 |
+ |
rayorigin(&sr, r, SPECULAR, np->tspec) == 0) { |
| 351 |
+ |
dimlist[ndims++] = (int)np->mp; |
| 352 |
+ |
d = urand(ilhash(dimlist,ndims)+1823+samplendx); |
| 353 |
+ |
multisamp(rv, 2, d); |
| 354 |
+ |
d = 2.0*PI * rv[0]; |
| 355 |
+ |
cosp = cos(d); |
| 356 |
+ |
sinp = sin(d); |
| 357 |
+ |
rv[1] = 1.0 - specjitter*rv[1]; |
| 358 |
+ |
if (rv[1] <= FTINY) |
| 359 |
+ |
d = 1.0; |
| 360 |
+ |
else |
| 361 |
+ |
d = sqrt( np->alpha2/4.0 * -log(rv[1]) ); |
| 362 |
+ |
for (i = 0; i < 3; i++) |
| 363 |
+ |
sr.rdir[i] = np->prdir[i] + d*(cosp*u[i] + sinp*v[i]); |
| 364 |
+ |
if (DOT(sr.rdir, r->ron) < -FTINY) |
| 365 |
+ |
normalize(sr.rdir); /* OK, normalize */ |
| 366 |
+ |
else |
| 367 |
+ |
VCOPY(sr.rdir, np->prdir); /* else no jitter */ |
| 368 |
+ |
rayvalue(&sr); |
| 369 |
+ |
multcolor(sr.rcol, np->scolor); |
| 370 |
+ |
addcolor(r->rcol, sr.rcol); |
| 371 |
+ |
ndims--; |
| 372 |
+ |
} |
| 373 |
|
} |