43 |
|
/* specularity flags */ |
44 |
|
#define SP_REFL 01 /* has reflected specular component */ |
45 |
|
#define SP_TRAN 02 /* has transmitted specular */ |
46 |
< |
#define SP_PURE 010 /* purely specular (zero roughness) */ |
47 |
< |
#define SP_FLAT 020 /* flat reflecting surface */ |
48 |
< |
#define SP_RBLT 040 /* reflection below sample threshold */ |
49 |
< |
#define SP_TBLT 0100 /* transmission below threshold */ |
46 |
> |
#define SP_PURE 04 /* purely specular (zero roughness) */ |
47 |
> |
#define SP_FLAT 010 /* flat reflecting surface */ |
48 |
> |
#define SP_RBLT 020 /* reflection below sample threshold */ |
49 |
> |
#define SP_TBLT 040 /* transmission below threshold */ |
50 |
|
|
51 |
|
typedef struct { |
52 |
|
OBJREC *mp; /* material pointer */ |
108 |
|
/* worth using? */ |
109 |
|
if (dtmp > FTINY) { |
110 |
|
copycolor(ctmp, np->scolor); |
111 |
< |
dtmp *= omega / np->pdot; |
111 |
> |
dtmp *= omega * sqrt(ldot/np->pdot); |
112 |
|
scalecolor(ctmp, dtmp); |
113 |
|
addcolor(cval, ctmp); |
114 |
|
} |
134 |
|
/* worth using? */ |
135 |
|
if (dtmp > FTINY) { |
136 |
|
copycolor(ctmp, np->mcolor); |
137 |
< |
dtmp *= np->tspec * omega / np->pdot; |
137 |
> |
dtmp *= np->tspec * omega * sqrt(ldot/np->pdot); |
138 |
|
scalecolor(ctmp, dtmp); |
139 |
|
addcolor(cval, ctmp); |
140 |
|
} |
186 |
|
else |
187 |
|
setcolor(nd.scolor, 1.0, 1.0, 1.0); |
188 |
|
scalecolor(nd.scolor, nd.rspec); |
189 |
< |
/* improved model */ |
190 |
< |
dtmp = exp(-BSPEC(m)*nd.pdot); |
191 |
< |
for (i = 0; i < 3; i++) |
192 |
< |
colval(nd.scolor,i) += (1.0-colval(nd.scolor,i))*dtmp; |
193 |
< |
nd.rspec += (1.0-nd.rspec)*dtmp; |
194 |
< |
/* check threshold */ |
195 |
< |
if (specthresh > FTINY && |
196 |
< |
((specthresh >= 1.-FTINY || |
197 |
< |
specthresh + (.1 - .2*urand(8199+samplendx)) |
198 |
< |
> nd.rspec))) |
189 |
> |
if (nd.specfl & SP_PURE) { /* improved model */ |
190 |
> |
dtmp = exp(-BSPEC(m)*nd.pdot); |
191 |
> |
for (i = 0; i < 3; i++) |
192 |
> |
colval(nd.scolor,i) += |
193 |
> |
(1.0-colval(nd.scolor,i))*dtmp; |
194 |
> |
nd.rspec += (1.0-nd.rspec)*dtmp; |
195 |
> |
} else if (specthresh > FTINY && /* check threshold */ |
196 |
> |
(specthresh >= 1.-FTINY || |
197 |
> |
specthresh > nd.rspec)) |
198 |
|
nd.specfl |= SP_RBLT; |
199 |
|
/* compute reflected ray */ |
200 |
|
for (i = 0; i < 3; i++) |
221 |
|
if (nd.tspec > FTINY) { |
222 |
|
nd.specfl |= SP_TRAN; |
223 |
|
/* check threshold */ |
224 |
< |
if (specthresh > FTINY && |
225 |
< |
((specthresh >= 1.-FTINY || |
226 |
< |
specthresh + |
228 |
< |
(.1 - .2*urand(7241+samplendx)) |
229 |
< |
> nd.tspec))) |
224 |
> |
if (!(nd.specfl & SP_PURE) && specthresh > FTINY && |
225 |
> |
(specthresh >= 1.-FTINY || |
226 |
> |
specthresh > nd.tspec)) |
227 |
|
nd.specfl |= SP_TBLT; |
228 |
|
if (r->crtype & SHADOW || |
229 |
|
DOT(r->pert,r->pert) <= FTINY*FTINY) { |
253 |
|
transtest *= bright(lr.rcol); |
254 |
|
transdist = r->rot + lr.rt; |
255 |
|
} |
256 |
< |
} |
256 |
> |
} else |
257 |
> |
transtest = 0; |
258 |
|
|
259 |
|
if (r->crtype & SHADOW) /* the rest is shadow */ |
260 |
|
return; |
264 |
|
if (nd.specfl & SP_PURE && nd.rdiff <= FTINY && nd.tdiff <= FTINY) |
265 |
|
return; /* 100% pure specular */ |
266 |
|
|
267 |
< |
if (r->ro->otype == OBJ_FACE || r->ro->otype == OBJ_RING) |
267 |
> |
if (r->ro != NULL && (r->ro->otype == OBJ_FACE || |
268 |
> |
r->ro->otype == OBJ_RING)) |
269 |
|
nd.specfl |= SP_FLAT; |
270 |
|
|
271 |
|
if (nd.specfl & (SP_REFL|SP_TRAN) && !(nd.specfl & SP_PURE)) |
309 |
|
double rv[2]; |
310 |
|
double d, sinp, cosp; |
311 |
|
register int i; |
312 |
+ |
/* quick test */ |
313 |
+ |
if ((np->specfl & (SP_REFL|SP_RBLT)) != SP_REFL && |
314 |
+ |
(np->specfl & (SP_TRAN|SP_TBLT)) != SP_TRAN) |
315 |
+ |
return; |
316 |
|
/* set up sample coordinates */ |
317 |
|
v[0] = v[1] = v[2] = 0.0; |
318 |
|
for (i = 0; i < 3; i++) |
369 |
|
else |
370 |
|
VCOPY(sr.rdir, np->prdir); /* else no jitter */ |
371 |
|
rayvalue(&sr); |
372 |
< |
multcolor(sr.rcol, np->scolor); |
372 |
> |
scalecolor(sr.rcol, np->tspec); |
373 |
> |
multcolor(sr.rcol, np->mcolor); /* modified by color */ |
374 |
|
addcolor(r->rcol, sr.rcol); |
375 |
|
ndims--; |
376 |
|
} |