74 |
|
COLOR ctrans; |
75 |
|
COLOR talb; |
76 |
|
int hastexture; |
77 |
+ |
double transdist, transtest=0; |
78 |
+ |
double mirdist, mirtest=0; |
79 |
+ |
int flatsurface; |
80 |
|
double refl, trans; |
81 |
|
FVECT dnorm; |
82 |
|
double d1, d2; |
94 |
|
VCOPY(dnorm, r->ron); |
95 |
|
cos1 = r->rod; |
96 |
|
} |
97 |
+ |
flatsurface = !hastexture && r->ro != NULL && isflat(r->ro->otype); |
98 |
+ |
|
99 |
|
/* index of refraction */ |
100 |
|
if (m->otype == MAT_DIELECTRIC) |
101 |
|
nratio = m->oargs.farg[3] + m->oargs.farg[4]/MLAMBDA; |
194 |
|
rayvalue(&p); |
195 |
|
scalecolor(p.rcol, trans); |
196 |
|
addcolor(r->rcol, p.rcol); |
197 |
< |
if (nratio >= 1.0-FTINY && nratio <= 1.0+FTINY) |
198 |
< |
r->rt = r->rot + p.rt; |
197 |
> |
/* virtual distance */ |
198 |
> |
if (flatsurface || |
199 |
> |
(1.-FTINY <= nratio && |
200 |
> |
nratio <= 1.+FTINY)) { |
201 |
> |
transtest = 2*bright(p.rcol); |
202 |
> |
transdist = r->rot + p.rt; |
203 |
> |
} |
204 |
|
} |
205 |
|
} |
206 |
|
} |
220 |
|
|
221 |
|
scalecolor(p.rcol, refl); /* color contribution */ |
222 |
|
addcolor(r->rcol, p.rcol); |
223 |
+ |
/* virtual distance */ |
224 |
+ |
if (flatsurface) { |
225 |
+ |
mirtest = 2*bright(p.rcol); |
226 |
+ |
mirdist = r->rot + p.rt; |
227 |
+ |
} |
228 |
|
} |
229 |
+ |
/* check distance to return */ |
230 |
+ |
d1 = bright(r->rcol); |
231 |
+ |
if (transtest > d1) |
232 |
+ |
r->rt = transdist; |
233 |
+ |
else if (mirtest > d1) |
234 |
+ |
r->rt = mirdist; |
235 |
|
/* rayvalue() computes absorption */ |
236 |
|
return(1); |
237 |
|
} |