23 |
|
extern double specthresh; /* specular sampling threshold */ |
24 |
|
extern double specjitter; /* specular sampling jitter */ |
25 |
|
|
26 |
+ |
static gaussamp(); |
27 |
+ |
|
28 |
|
/* |
29 |
|
* This routine implements the isotropic Gaussian |
30 |
|
* model described by Ward in Siggraph `92 article. |
38 |
|
* red grn blu rspec rough trans tspec |
39 |
|
*/ |
40 |
|
|
39 |
– |
#define BSPEC(m) (6.0) /* specularity parameter b */ |
40 |
– |
|
41 |
|
/* specularity flags */ |
42 |
|
#define SP_REFL 01 /* has reflected specular component */ |
43 |
|
#define SP_TRAN 02 /* has transmitted specular */ |
154 |
|
{ |
155 |
|
NORMDAT nd; |
156 |
|
double transtest, transdist; |
157 |
– |
double dtmp; |
157 |
|
COLOR ctmp; |
158 |
|
register int i; |
159 |
|
/* easy shadow test */ |
183 |
|
nd.pdot = .001; /* non-zero for dirnorm() */ |
184 |
|
multcolor(nd.mcolor, r->pcol); /* modify material color */ |
185 |
|
transtest = 0; |
186 |
+ |
transdist = r->rot; |
187 |
|
/* get specular component */ |
188 |
|
if ((nd.rspec = m->oargs.farg[3]) > FTINY) { |
189 |
|
nd.specfl |= SP_REFL; |
193 |
|
else |
194 |
|
setcolor(nd.scolor, 1.0, 1.0, 1.0); |
195 |
|
scalecolor(nd.scolor, nd.rspec); |
196 |
– |
/* improved model */ |
197 |
– |
dtmp = exp(-BSPEC(m)*nd.pdot); |
198 |
– |
for (i = 0; i < 3; i++) |
199 |
– |
colval(nd.scolor,i) += (1.0-colval(nd.scolor,i))*dtmp; |
200 |
– |
nd.rspec += (1.0-nd.rspec)*dtmp; |
196 |
|
/* check threshold */ |
197 |
< |
if (!(nd.specfl & SP_PURE) && |
203 |
< |
specthresh > FTINY && |
204 |
< |
(specthresh >= 1.-FTINY || |
205 |
< |
specthresh + .05 - .1*frandom() > nd.rspec)) |
197 |
> |
if (!(nd.specfl & SP_PURE) && specthresh >= nd.rspec-FTINY) |
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 (!(nd.specfl & SP_PURE) && specthresh > FTINY && |
225 |
< |
(specthresh >= 1.-FTINY || |
234 |
< |
specthresh + .05 - .1*frandom() > nd.tspec)) |
224 |
> |
if (!(nd.specfl & SP_PURE) && |
225 |
> |
specthresh >= nd.tspec-FTINY) |
226 |
|
nd.specfl |= SP_TBLT; |
227 |
|
if (r->crtype & SHADOW || |
228 |
|
DOT(r->pert,r->pert) <= FTINY*FTINY) { |