--- ray/src/rt/glass.c 1991/11/12 17:09:32 2.1 +++ ray/src/rt/glass.c 1992/10/14 12:27:47 2.4 @@ -46,7 +46,6 @@ m_glass(m, r) /* color a ray which hit a thin glass s OBJREC *m; register RAY *r; { - double sqrt(), pow(); COLOR mcolor; double pdot; FVECT pnorm; @@ -95,8 +94,12 @@ register RAY *r; if (!(r->crtype & SHADOW) && 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); + p.rdir[i] = r->rdir[i] + + 2.*(1.-rindex)*r->pert[i]; + if (normalize(p.rdir) == 0.0) { + objerror(m, WARNING, "bad perturbation"); + VCOPY(p.rdir, r->rdir); + } } else { VCOPY(p.rdir, r->rdir); transtest = 2;