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.12 by greg, Mon Aug 12 08:20:55 1991 UTC vs.
Revision 2.1 by greg, Tue Nov 12 17:09:11 1991 UTC

# Line 38 | Line 38 | extern double  exp();
38  
39   typedef struct {
40          OBJREC  *mp;            /* material pointer */
41        RAY  *pr;               /* intersected ray */
41          COLOR  mcolor;          /* color of this material */
42          COLOR  scolor;          /* color of specular component */
43          FVECT  vrefl;           /* vector in direction of reflected ray */
44 +        FVECT  prdir;           /* vector in transmitted direction */
45          double  alpha2;         /* roughness squared times 2 */
46          double  rdiff, rspec;   /* reflected specular, diffuse */
47          double  trans;          /* transmissivity */
# 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);
115                                                  /* gaussian */
116 <                dtmp = exp((DOT(np->pr->rdir,ldir)-1.)/dtmp)/(2.*PI)/dtmp;
116 >                dtmp = exp((DOT(np->prdir,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 140 | Line 141 | register RAY  *r;
141          if (r->crtype & SHADOW && m->otype != MAT_TRANS)
142                  return;
143          nd.mp = m;
143        nd.pr = r;
144                                                  /* get material color */
145          setcolor(nd.mcolor, m->oargs.farg[0],
146                             m->oargs.farg[1],
# Line 154 | Line 154 | register RAY  *r;
154                                                  /* get modifiers */
155          raytexture(r, m->omod);
156          nd.pdot = raynormal(nd.pnorm, r);       /* perturb normal */
157 +        if (nd.pdot < .001)
158 +                nd.pdot = .001;                 /* non-zero for dirnorm() */
159          multcolor(nd.mcolor, r->pcol);          /* modify material color */
160          transtest = 0;
161                                                  /* get specular component */
# Line 190 | Line 192 | register RAY  *r;
192                  nd.trans = m->oargs.farg[5]*(1.0 - nd.rspec);
193                  nd.tspec = nd.trans * m->oargs.farg[6];
194                  nd.tdiff = nd.trans - nd.tspec;
195 +                if (r->crtype & SHADOW || DOT(r->pert,r->pert) <= FTINY*FTINY) {
196 +                        VCOPY(nd.prdir, r->rdir);
197 +                        transtest = 2;
198 +                } else {
199 +                        for (i = 0; i < 3; i++)         /* perturb direction */
200 +                                nd.prdir[i] = r->rdir[i] - .75*r->pert[i];
201 +                        normalize(nd.prdir);
202 +                }
203          } else
204                  nd.tdiff = nd.tspec = nd.trans = 0.0;
205                                                  /* transmitted ray */
206          if (nd.tspec > FTINY && nd.alpha2 <= FTINY) {
207                  RAY  lr;
208                  if (rayorigin(&lr, r, TRANS, nd.tspec) == 0) {
209 <                        if (!(r->crtype & SHADOW) &&
200 <                                        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 >                        VCOPY(lr.rdir, nd.prdir);
210                          rayvalue(&lr);
211                          scalecolor(lr.rcol, nd.tspec);
212                          multcolor(lr.rcol, nd.mcolor);  /* modified by color */
# Line 238 | Line 239 | register RAY  *r;
239                          scalecolor(ctmp, nd.tdiff);
240                  else
241                          scalecolor(ctmp, nd.trans);
242 <                multcolor(ctmp, nd.mcolor);
242 >                multcolor(ctmp, nd.mcolor);     /* modified by color */
243                  addcolor(r->rcol, ctmp);
244                  flipsurface(r);
245          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines