--- ray/src/rt/glass.c 1990/03/27 11:40:00 1.3 +++ ray/src/rt/glass.c 1991/06/13 13:58:20 1.9 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -50,6 +50,7 @@ register RAY *r; double cos2; COLOR trans, refl; double d, r1; + double transtest, transdist; RAY p; register int i; @@ -60,6 +61,7 @@ register RAY *r; if (r->rod < 0.0) /* reorient if necessary */ flipsurface(r); + transtest = 0; /* get modifiers */ raytexture(r, m->omod); pdot = raynormal(pnorm, r); @@ -81,12 +83,20 @@ register RAY *r; } /* transmitted ray */ if (rayorigin(&p, r, TRANS, bright(trans)) == 0) { - VCOPY(p.rdir, r->rdir); + if (DOT(r->pert,r->pert) > FTINY*FTINY) { + for (i = 0; i < 3; i++) /* perturb direction */ + p.rdir[i] = r->rdir[i] - r->pert[i]/RINDEX; + normalize(p.rdir); + } else { + VCOPY(p.rdir, r->rdir); + transtest = 2; + } rayvalue(&p); multcolor(p.rcol, r->pcol); /* modify */ multcolor(p.rcol, trans); addcolor(r->rcol, p.rcol); - r->rt = r->rot + p.rt; + transtest *= bright(p.rcol); + transdist = r->rot + p.rt; } if (r->crtype & SHADOW) /* skip reflected ray */ @@ -104,7 +114,7 @@ register RAY *r; rayvalue(&p); multcolor(p.rcol, refl); addcolor(r->rcol, p.rcol); - if (bright(refl) > bright(trans)) - r->rt = r->rot + p.rt; } + if (transtest > bright(r->rcol)) + r->rt = transdist; }