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.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 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 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 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 always modified by material color.
112                   */
113                                                  /* roughness + source */
114                  dtmp = np->alpha2 + omega/(2.0*PI);
# Line 116 | Line 117 | double  omega;                 /* light source size */
117                                                  /* worth using? */
118                  if (dtmp > FTINY) {
119                          copycolor(ctmp, np->mcolor);
120 <                        dtmp *= np->tspec * omega;
120 >                        dtmp *= np->tspec * omega / np->pdot;
121                          scalecolor(ctmp, dtmp);
122                          addcolor(cval, ctmp);
123                  }
# Line 129 | Line 130 | register OBJREC  *m;
130   register RAY  *r;
131   {
132          NORMDAT  nd;
133 <        double  ldot;
133 <        double  omega;
133 >        double  transtest, transdist;
134          double  dtmp;
135          COLOR  ctmp;
136          register int  i;
# Line 155 | 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 +        transtest = 0;
162                                                  /* get specular component */
163          nd.rspec = m->oargs.farg[3];
164  
# Line 196 | 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 <                        VCOPY(lr.rdir, r->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 +                        transtest *= bright(lr.rcol);
217 +                        transdist = r->rot + lr.rt;
218                  }
219          }
220          if (r->crtype & SHADOW)                 /* the rest is shadow */
# Line 226 | 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