ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/normal.c
(Generate patch)

Comparing ray/src/rt/normal.c (file contents):
Revision 1.8 by greg, Tue May 7 17:45:49 1991 UTC vs.
Revision 1.9 by greg, Wed May 8 08:27:48 1991 UTC

# Line 1 | Line 1
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";
# Line 129 | Line 129 | register OBJREC  *m;
129   register RAY  *r;
130   {
131          NORMDAT  nd;
132 +        double  transtest, transdist;
133          double  dtmp;
134          COLOR  ctmp;
135          register int  i;
# Line 155 | Line 156 | register RAY  *r;
156          nd.pdot = raynormal(nd.pnorm, r);       /* perturb normal */
157          multcolor(nd.mcolor, r->pcol);          /* modify material color */
158          r->rt = r->rot;                         /* default ray length */
159 +        transtest = 0;
160                                                  /* get specular component */
161          nd.rspec = m->oargs.farg[3];
162  
# Line 195 | Line 197 | register RAY  *r;
197          if (nd.tspec > FTINY && nd.alpha2 <= FTINY) {
198                  RAY  lr;
199                  if (rayorigin(&lr, r, TRANS, nd.tspec) == 0) {
200 <                        for (i = 0; i < 3; i++)         /* perturb direction */
201 <                                lr.rdir[i] = r->rdir[i] - .75*r->pert[i];
202 <                        normalize(lr.rdir);
200 >                        if (DOT(r->pert,r->pert) > FTINY*FTINY) {
201 >                                for (i = 0; i < 3; i++) /* perturb direction */
202 >                                        lr.rdir[i] = r->rdir[i] -
203 >                                                        .75*r->pert[i];
204 >                                normalize(lr.rdir);
205 >                        } else
206 >                                transtest = 2;
207                          rayvalue(&lr);
208                          scalecolor(lr.rcol, nd.tspec);
209                          multcolor(lr.rcol, nd.mcolor);  /* modified by color */
210                          addcolor(r->rcol, lr.rcol);
211 <                        if (nd.tspec > .5)
212 <                                r->rt = r->rot + lr.rt;
211 >                        transtest *= bright(lr.rcol);
212 >                        transdist = r->rot + lr.rt;
213                  }
214          }
215          if (r->crtype & SHADOW)                 /* the rest is shadow */
# Line 236 | Line 242 | register RAY  *r;
242          }
243                                          /* add direct component */
244          direct(r, dirnorm, &nd);
245 +                                        /* check distance */
246 +        if (transtest > bright(r->rcol))
247 +                r->rt = transdist;
248   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines