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 2.15 by greg, Wed Apr 22 09:05:30 1992 UTC vs.
Revision 2.16 by greg, Wed May 6 17:36:00 1992 UTC

# Line 50 | Line 50 | extern double  specjitter;             /* specular sampling jitte
50  
51   typedef struct {
52          OBJREC  *mp;            /* material pointer */
53 +        RAY  *rp;               /* ray pointer */
54          short  specfl;          /* specularity flags, defined above */
55          COLOR  mcolor;          /* color of this material */
56          COLOR  scolor;          /* color of specular component */
# Line 71 | Line 72 | FVECT  ldir;                   /* light source direction */
72   double  omega;                  /* light source size */
73   {
74          double  ldot;
75 <        double  dtmp;
76 <        int     i;
75 >        double  dtmp, d2;
76 >        FVECT  vtmp;
77 >        register int    i;
78          COLOR  ctmp;
79  
80          setcolor(cval, 0.0, 0.0, 0.0);
# Line 99 | Line 101 | double  omega;                 /* light source size */
101                   *  gaussian distribution model.
102                   */
103                                                  /* roughness */
104 <                dtmp = 2.0*np->alpha2;
104 >                dtmp = np->alpha2;
105                                                  /* + source if flat */
106                  if (np->specfl & SP_FLAT)
107 <                        dtmp += omega/(2.0*PI);
107 >                        dtmp += omega/(4.0*PI);
108 >                                                /* delta */
109 >                for (i = 0; i < 3; i++)
110 >                        vtmp[i] = ldir[i] - np->rp->rdir[i];
111 >                d2 = DOT(vtmp, np->pnorm);
112 >                d2 = 2.0 - 2.0*d2/sqrt(DOT(vtmp,vtmp));
113                                                  /* gaussian */
114 <                dtmp = exp((DOT(np->vrefl,ldir)-1.)/dtmp)/(2.*PI)/dtmp;
114 >                dtmp = exp(-d2/dtmp)/(4.*PI*dtmp);
115                                                  /* worth using? */
116                  if (dtmp > FTINY) {
117                          copycolor(ctmp, np->scolor);
# Line 158 | Line 165 | register RAY  *r;
165          if (m->oargs.nfargs != (m->otype == MAT_TRANS ? 7 : 5))
166                  objerror(m, USER, "bad number of arguments");
167          nd.mp = m;
168 +        nd.rp = r;
169                                                  /* get material color */
170          setcolor(nd.mcolor, m->oargs.farg[0],
171                             m->oargs.farg[1],

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines