34 |
|
* 8 red grn blu rspec u-rough v-rough trans tspec |
35 |
|
*/ |
36 |
|
|
37 |
– |
#define BSPEC(m) (6.0) /* specularity parameter b */ |
38 |
– |
|
37 |
|
/* specularity flags */ |
38 |
|
#define SP_REFL 01 /* has reflected specular component */ |
39 |
|
#define SP_TRAN 02 /* has transmitted specular */ |
196 |
|
else |
197 |
|
setcolor(nd.scolor, 1.0, 1.0, 1.0); |
198 |
|
scalecolor(nd.scolor, nd.rspec); |
201 |
– |
/* improved model */ |
202 |
– |
dtmp = exp(-BSPEC(m)*nd.pdot); |
203 |
– |
for (i = 0; i < 3; i++) |
204 |
– |
colval(nd.scolor,i) += (1.0-colval(nd.scolor,i))*dtmp; |
205 |
– |
nd.rspec += (1.0-nd.rspec)*dtmp; |
199 |
|
/* check threshold */ |
200 |
|
if (specthresh > FTINY && |
201 |
< |
((specthresh >= 1.-FTINY || |
202 |
< |
specthresh + (.05 - .1*frandom()) > nd.rspec))) |
201 |
> |
(specthresh >= 1.-FTINY || |
202 |
> |
specthresh > nd.rspec)) |
203 |
|
nd.specfl |= SP_RBLT; |
204 |
|
/* compute refl. direction */ |
205 |
|
for (i = 0; i < 3; i++) |
217 |
|
nd.specfl |= SP_TRAN; |
218 |
|
/* check threshold */ |
219 |
|
if (specthresh > FTINY && |
220 |
< |
((specthresh >= 1.-FTINY || |
221 |
< |
specthresh + |
229 |
< |
(.05 - .1*frandom()) > nd.tspec))) |
220 |
> |
(specthresh >= 1.-FTINY || |
221 |
> |
specthresh > nd.tspec)) |
222 |
|
nd.specfl |= SP_TBLT; |
223 |
|
if (DOT(r->pert,r->pert) <= FTINY*FTINY) { |
224 |
|
VCOPY(nd.prdir, r->rdir); |
238 |
|
/* diffuse reflection */ |
239 |
|
nd.rdiff = 1.0 - nd.trans - nd.rspec; |
240 |
|
|
241 |
< |
if (r->ro->otype == OBJ_FACE || r->ro->otype == OBJ_RING) |
241 |
> |
if (r->ro != NULL && (r->ro->otype == OBJ_FACE || |
242 |
> |
r->ro->otype == OBJ_RING)) |
243 |
|
nd.specfl |= SP_FLAT; |
244 |
|
|
245 |
|
getacoords(r, &nd); /* set up coordinates */ |