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"; |
50 |
|
double cos2; |
51 |
|
COLOR trans, refl; |
52 |
|
double d, r1; |
53 |
+ |
double transtest, transdist; |
54 |
|
RAY p; |
55 |
|
register int i; |
56 |
|
|
61 |
|
|
62 |
|
if (r->rod < 0.0) /* reorient if necessary */ |
63 |
|
flipsurface(r); |
64 |
< |
r->rt = r->rot; /* default ray length */ |
64 |
> |
transtest = 0; |
65 |
|
/* get modifiers */ |
66 |
|
raytexture(r, m->omod); |
67 |
|
pdot = raynormal(pnorm, r); |
83 |
|
} |
84 |
|
/* transmitted ray */ |
85 |
|
if (rayorigin(&p, r, TRANS, bright(trans)) == 0) { |
86 |
< |
for (i = 0; i < 3; i++) /* perturb direction */ |
87 |
< |
p.rdir[i] = r->rdir[i] - r->pert[i]/RINDEX; |
88 |
< |
normalize(p.rdir); |
86 |
> |
if (!(r->crtype & SHADOW) && |
87 |
> |
DOT(r->pert,r->pert) > FTINY*FTINY) { |
88 |
> |
for (i = 0; i < 3; i++) /* perturb direction */ |
89 |
> |
p.rdir[i] = r->rdir[i] - r->pert[i]/RINDEX; |
90 |
> |
normalize(p.rdir); |
91 |
> |
} else { |
92 |
> |
VCOPY(p.rdir, r->rdir); |
93 |
> |
transtest = 2; |
94 |
> |
} |
95 |
|
rayvalue(&p); |
96 |
|
multcolor(p.rcol, r->pcol); /* modify */ |
97 |
|
multcolor(p.rcol, trans); |
98 |
|
addcolor(r->rcol, p.rcol); |
99 |
< |
if (bright(p.rcol) > .5) |
100 |
< |
r->rt = r->rot + p.rt; |
99 |
> |
transtest *= bright(p.rcol); |
100 |
> |
transdist = r->rot + p.rt; |
101 |
|
} |
102 |
|
|
103 |
|
if (r->crtype & SHADOW) /* skip reflected ray */ |
116 |
|
multcolor(p.rcol, refl); |
117 |
|
addcolor(r->rcol, p.rcol); |
118 |
|
} |
119 |
+ |
if (transtest > bright(r->rcol)) |
120 |
+ |
r->rt = transdist; |
121 |
|
} |