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.3 by greg, Wed Jun 7 08:35:14 1989 UTC vs.
Revision 1.10 by greg, Fri May 10 08:51:04 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 70 | Line 70 | double  omega;                 /* light source size */
70  
71          if (ldot > FTINY && np->rdiff > FTINY) {
72                  /*
73 <                 *  Compute and add diffuse component to returned color.
74 <                 *  The diffuse component will always be modified by the
75 <                 *  color of the material.
73 >                 *  Compute and add diffuse reflected component to returned
74 >                 *  color.  The diffuse reflected component will always be
75 >                 *  modified by the color of the material.
76                   */
77                  copycolor(ctmp, np->mcolor);
78                  dtmp = ldot * omega * np->rdiff / PI;
# Line 107 | Line 107 | double  omega;                 /* light source size */
107          }
108          if (ldot < -FTINY && np->tspec > FTINY && np->alpha2 > FTINY) {
109                  /*
110 <                 *  Compute specular transmission.
110 >                 *  Compute specular transmission.  Specular transmission
111 >                 *  is unaffected by material color.
112                   */
113                                                  /* roughness + source */
114                  dtmp = np->alpha2 + omega/(2.0*PI);
# Line 115 | Line 116 | double  omega;                 /* light source size */
116                  dtmp = exp((DOT(np->pr->rdir,ldir)-1.)/dtmp)/(2.*PI)/dtmp;
117                                                  /* worth using? */
118                  if (dtmp > FTINY) {
118                        copycolor(ctmp, np->mcolor);
119                          dtmp *= np->tspec * omega;
120 <                        scalecolor(ctmp, dtmp);
120 >                        setcolor(ctmp, dtmp, dtmp, dtmp);
121                          addcolor(cval, ctmp);
122                  }
123          }
# Line 129 | Line 129 | register OBJREC  *m;
129   register RAY  *r;
130   {
131          NORMDAT  nd;
132 <        double  ldot;
133 <        double  omega;
132 >        double  transtest, transdist;
133          double  dtmp;
134          COLOR  ctmp;
135          register int  i;
# Line 156 | Line 155 | register RAY  *r;
155          raytexture(r, m->omod);
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 196 | 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 <                        VCOPY(lr.rdir, r->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 >                                VCOPY(lr.rdir, r->rdir);
207 >                                transtest = 2;
208 >                        }
209                          rayvalue(&lr);
210                          scalecolor(lr.rcol, nd.tspec);
211 +                        multcolor(lr.rcol, nd.mcolor);  /* modified by color */
212                          addcolor(r->rcol, lr.rcol);
213 +                        transtest *= bright(lr.rcol);
214 +                        transdist = r->rot + lr.rt;
215                  }
216          }
217          if (r->crtype & SHADOW)                 /* the rest is shadow */
# Line 232 | Line 244 | register RAY  *r;
244          }
245                                          /* add direct component */
246          direct(r, dirnorm, &nd);
247 +                                        /* check distance */
248 +        if (transtest > bright(r->rcol))
249 +                r->rt = transdist;
250   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines