36 |
|
* 8 red grn blu rspec u-rough v-rough trans tspec |
37 |
|
*/ |
38 |
|
|
39 |
– |
#define BSPEC(m) (6.0) /* specularity parameter b */ |
40 |
– |
|
39 |
|
/* specularity flags */ |
40 |
|
#define SP_REFL 01 /* has reflected specular component */ |
41 |
|
#define SP_TRAN 02 /* has transmitted specular */ |
181 |
|
register RAY *r; |
182 |
|
{ |
183 |
|
ANISODAT nd; |
186 |
– |
double dtmp; |
184 |
|
COLOR ctmp; |
185 |
|
register int i; |
186 |
|
/* easy shadow test */ |
219 |
|
else |
220 |
|
setcolor(nd.scolor, 1.0, 1.0, 1.0); |
221 |
|
scalecolor(nd.scolor, nd.rspec); |
225 |
– |
/* improved model */ |
226 |
– |
dtmp = exp(-BSPEC(m)*nd.pdot); |
227 |
– |
for (i = 0; i < 3; i++) |
228 |
– |
colval(nd.scolor,i) += (1.0-colval(nd.scolor,i))*dtmp; |
229 |
– |
nd.rspec += (1.0-nd.rspec)*dtmp; |
222 |
|
/* check threshold */ |
223 |
< |
if (specthresh > FTINY && |
232 |
< |
(specthresh >= 1.-FTINY || |
233 |
< |
specthresh + .05 - .1*frandom() > nd.rspec)) |
223 |
> |
if (specthresh >= nd.rspec-FTINY) |
224 |
|
nd.specfl |= SP_RBLT; |
225 |
|
/* compute refl. direction */ |
226 |
|
for (i = 0; i < 3; i++) |
237 |
|
if (nd.tspec > FTINY) { |
238 |
|
nd.specfl |= SP_TRAN; |
239 |
|
/* check threshold */ |
240 |
< |
if (specthresh > FTINY && |
251 |
< |
(specthresh >= 1.-FTINY || |
252 |
< |
specthresh + .05 - .1*frandom() > nd.tspec)) |
240 |
> |
if (specthresh >= nd.tspec-FTINY) |
241 |
|
nd.specfl |= SP_TBLT; |
242 |
|
if (DOT(r->pert,r->pert) <= FTINY*FTINY) { |
243 |
|
VCOPY(nd.prdir, r->rdir); |