1 |
< |
/* Copyright (c) 1986 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1991 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
91 |
|
/* worth using? */ |
92 |
|
if (dtmp > FTINY) { |
93 |
|
copycolor(ctmp, np->scolor); |
94 |
< |
dtmp *= omega; |
94 |
> |
dtmp *= omega / np->pdot; |
95 |
|
scalecolor(ctmp, dtmp); |
96 |
|
addcolor(cval, ctmp); |
97 |
|
} |
108 |
|
if (ldot < -FTINY && np->tspec > FTINY && np->alpha2 > FTINY) { |
109 |
|
/* |
110 |
|
* Compute specular transmission. Specular transmission |
111 |
< |
* is unaffected by material color. |
111 |
> |
* is always modified by material color. |
112 |
|
*/ |
113 |
|
/* roughness + source */ |
114 |
|
dtmp = np->alpha2 + omega/(2.0*PI); |
116 |
|
dtmp = exp((DOT(np->pr->rdir,ldir)-1.)/dtmp)/(2.*PI)/dtmp; |
117 |
|
/* worth using? */ |
118 |
|
if (dtmp > FTINY) { |
119 |
< |
dtmp *= np->tspec * omega; |
120 |
< |
setcolor(ctmp, dtmp, dtmp, dtmp); |
119 |
> |
copycolor(ctmp, np->mcolor); |
120 |
> |
dtmp *= np->tspec * omega / np->pdot; |
121 |
> |
scalecolor(ctmp, dtmp); |
122 |
|
addcolor(cval, ctmp); |
123 |
|
} |
124 |
|
} |
130 |
|
register RAY *r; |
131 |
|
{ |
132 |
|
NORMDAT nd; |
133 |
< |
double ldot; |
133 |
< |
double omega; |
133 |
> |
double transtest, transdist; |
134 |
|
double dtmp; |
135 |
|
COLOR ctmp; |
136 |
|
register int i; |
155 |
|
/* get modifiers */ |
156 |
|
raytexture(r, m->omod); |
157 |
|
nd.pdot = raynormal(nd.pnorm, r); /* perturb normal */ |
158 |
+ |
if (nd.pdot < .001) |
159 |
+ |
nd.pdot = .001; /* non-zero for dirnorm() */ |
160 |
|
multcolor(nd.mcolor, r->pcol); /* modify material color */ |
161 |
< |
r->rt = r->rot; /* default ray length */ |
161 |
> |
transtest = 0; |
162 |
|
/* get specular component */ |
163 |
|
nd.rspec = m->oargs.farg[3]; |
164 |
|
|
185 |
|
rayvalue(&lr); |
186 |
|
multcolor(lr.rcol, nd.scolor); |
187 |
|
addcolor(r->rcol, lr.rcol); |
186 |
– |
if (nd.rspec > 0.5 && m->omod == OVOID) |
187 |
– |
r->rt = r->rot + lr.rt; |
188 |
|
} |
189 |
|
} |
190 |
|
} |
199 |
|
if (nd.tspec > FTINY && nd.alpha2 <= FTINY) { |
200 |
|
RAY lr; |
201 |
|
if (rayorigin(&lr, r, TRANS, nd.tspec) == 0) { |
202 |
< |
VCOPY(lr.rdir, r->rdir); |
202 |
> |
if (!(r->crtype & SHADOW) && |
203 |
> |
DOT(r->pert,r->pert) > FTINY*FTINY) { |
204 |
> |
for (i = 0; i < 3; i++) /* perturb direction */ |
205 |
> |
lr.rdir[i] = r->rdir[i] - |
206 |
> |
.75*r->pert[i]; |
207 |
> |
normalize(lr.rdir); |
208 |
> |
} else { |
209 |
> |
VCOPY(lr.rdir, r->rdir); |
210 |
> |
transtest = 2; |
211 |
> |
} |
212 |
|
rayvalue(&lr); |
213 |
|
scalecolor(lr.rcol, nd.tspec); |
214 |
+ |
multcolor(lr.rcol, nd.mcolor); /* modified by color */ |
215 |
|
addcolor(r->rcol, lr.rcol); |
216 |
< |
if (nd.tspec > .5) |
217 |
< |
r->rt = r->rot + lr.rt; |
216 |
> |
transtest *= bright(lr.rcol); |
217 |
> |
transdist = r->rot + lr.rt; |
218 |
|
} |
219 |
|
} |
220 |
|
if (r->crtype & SHADOW) /* the rest is shadow */ |
241 |
|
scalecolor(ctmp, nd.tdiff); |
242 |
|
else |
243 |
|
scalecolor(ctmp, nd.trans); |
244 |
< |
multcolor(ctmp, nd.mcolor); |
244 |
> |
multcolor(ctmp, nd.mcolor); /* modified by color */ |
245 |
|
addcolor(r->rcol, ctmp); |
246 |
|
flipsurface(r); |
247 |
|
} |
248 |
|
/* add direct component */ |
249 |
|
direct(r, dirnorm, &nd); |
250 |
+ |
/* check distance */ |
251 |
+ |
if (transtest > bright(r->rcol)) |
252 |
+ |
r->rt = transdist; |
253 |
|
} |