| 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 |
+ |
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 |
< |
VCOPY(p.rdir, r->rdir); |
| 86 |
> |
if (DOT(r->pert,r->pert) > FTINY*FTINY) { |
| 87 |
> |
for (i = 0; i < 3; i++) /* perturb direction */ |
| 88 |
> |
p.rdir[i] = r->rdir[i] - r->pert[i]/RINDEX; |
| 89 |
> |
normalize(p.rdir); |
| 90 |
> |
} else { |
| 91 |
> |
VCOPY(p.rdir, r->rdir); |
| 92 |
> |
transtest = 2; |
| 93 |
> |
} |
| 94 |
|
rayvalue(&p); |
| 95 |
|
multcolor(p.rcol, r->pcol); /* modify */ |
| 96 |
|
multcolor(p.rcol, trans); |
| 97 |
|
addcolor(r->rcol, p.rcol); |
| 98 |
+ |
transtest *= bright(p.rcol); |
| 99 |
+ |
transdist = r->rot + p.rt; |
| 100 |
|
} |
| 101 |
+ |
|
| 102 |
|
if (r->crtype & SHADOW) /* skip reflected ray */ |
| 103 |
|
return; |
| 104 |
|
/* compute reflectance */ |
| 115 |
|
multcolor(p.rcol, refl); |
| 116 |
|
addcolor(r->rcol, p.rcol); |
| 117 |
|
} |
| 118 |
+ |
if (transtest > bright(r->rcol)) |
| 119 |
+ |
r->rt = transdist; |
| 120 |
|
} |