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.13 by greg, Wed Oct 30 10:59:42 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 91 | Line 91 | double  omega;                 /* light source size */
91                                                  /* worth using? */
92                  if (dtmp > FTINY) {
93                          copycolor(ctmp, np->scolor);
94 <                        dtmp *= omega;
94 >                        dtmp *= omega / np->pdot;
95                          scalecolor(ctmp, dtmp);
96                          addcolor(cval, ctmp);
97                  }
# Line 108 | Line 108 | double  omega;                 /* light source size */
108          if (ldot < -FTINY && np->tspec > FTINY && np->alpha2 > FTINY) {
109                  /*
110                   *  Compute specular transmission.  Specular transmission
111 <                 *  is unaffected by material color.
111 >                 *  is always modified by material color.
112                   */
113                                                  /* roughness + source */
114                  dtmp = np->alpha2 + omega/(2.0*PI);
# Line 116 | 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) {
119 <                        dtmp *= np->tspec * omega;
120 <                        setcolor(ctmp, dtmp, dtmp, dtmp);
119 >                        copycolor(ctmp, np->mcolor);
120 >                        dtmp *= np->tspec * omega / np->pdot;
121 >                        scalecolor(ctmp, dtmp);
122                          addcolor(cval, ctmp);
123                  }
124          }
# Line 129 | Line 130 | register OBJREC  *m;
130   register RAY  *r;
131   {
132          NORMDAT  nd;
133 +        double  transtest, transdist;
134          double  dtmp;
135          COLOR  ctmp;
136          register int  i;
# Line 153 | Line 155 | register RAY  *r;
155                                                  /* get modifiers */
156          raytexture(r, m->omod);
157          nd.pdot = raynormal(nd.pnorm, r);       /* perturb normal */
158 +        if (nd.pdot < .001)
159 +                nd.pdot = .001;                 /* non-zero for dirnorm() */
160          multcolor(nd.mcolor, r->pcol);          /* modify material color */
161 <        r->rt = r->rot;                         /* default ray length */
161 >        transtest = 0;
162                                                  /* get specular component */
163          nd.rspec = m->oargs.farg[3];
164  
# Line 195 | Line 199 | register RAY  *r;
199          if (nd.tspec > FTINY && nd.alpha2 <= FTINY) {
200                  RAY  lr;
201                  if (rayorigin(&lr, r, TRANS, nd.tspec) == 0) {
202 <                        for (i = 0; i < 3; i++)         /* perturb direction */
203 <                                lr.rdir[i] = r->rdir[i] - .75*r->pert[i];
204 <                        normalize(lr.rdir);
202 >                        if (!(r->crtype & SHADOW) &&
203 >                                        DOT(r->pert,r->pert) > FTINY*FTINY) {
204 >                                for (i = 0; i < 3; i++) /* perturb direction */
205 >                                        lr.rdir[i] = r->rdir[i] -
206 >                                                        .75*r->pert[i];
207 >                                normalize(lr.rdir);
208 >                        } else {
209 >                                VCOPY(lr.rdir, r->rdir);
210 >                                transtest = 2;
211 >                        }
212                          rayvalue(&lr);
213                          scalecolor(lr.rcol, nd.tspec);
214                          multcolor(lr.rcol, nd.mcolor);  /* modified by color */
215                          addcolor(r->rcol, lr.rcol);
216 <                        if (nd.tspec > .5)
217 <                                r->rt = r->rot + lr.rt;
216 >                        transtest *= bright(lr.rcol);
217 >                        transdist = r->rot + lr.rt;
218                  }
219          }
220          if (r->crtype & SHADOW)                 /* the rest is shadow */
# Line 230 | Line 241 | register RAY  *r;
241                          scalecolor(ctmp, nd.tdiff);
242                  else
243                          scalecolor(ctmp, nd.trans);
244 <                multcolor(ctmp, nd.mcolor);
244 >                multcolor(ctmp, nd.mcolor);     /* modified by color */
245                  addcolor(r->rcol, ctmp);
246                  flipsurface(r);
247          }
248                                          /* add direct component */
249          direct(r, dirnorm, &nd);
250 +                                        /* check distance */
251 +        if (transtest > bright(r->rcol))
252 +                r->rt = transdist;
253   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines