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.53 by greg, Sun Sep 26 15:51:15 2010 UTC vs.
Revision 2.54 by greg, Fri Oct 1 18:11:18 2010 UTC

# Line 80 | Line 80 | dirnorm(               /* compute source contribution */
80          register NORMDAT *np = nnp;
81          double  ldot;
82          double  lrdiff, ltdiff;
83 <        double  dtmp, d2;
83 >        double  dtmp, d2, d3, d4;
84          FVECT  vtmp;
85          COLOR  ctmp;
86  
# Line 115 | Line 115 | dirnorm(               /* compute source contribution */
115          if (ldot > FTINY && (np->specfl&(SP_REFL|SP_PURE)) == SP_REFL) {
116                  /*
117                   *  Compute specular reflection coefficient using
118 <                 *  gaussian distribution model.
118 >                 *  Gaussian distribution model.
119                   */
120                                                  /* roughness */
121                  dtmp = np->alpha2;
# Line 128 | Line 128 | dirnorm(               /* compute source contribution */
128                  vtmp[2] = ldir[2] - np->rp->rdir[2];
129                  d2 = DOT(vtmp, np->pnorm);
130                  d2 *= d2;
131 <                d2 = (DOT(vtmp,vtmp) - d2) / d2;
132 <                                                /* gaussian */
133 <                dtmp = exp(-d2/dtmp)/(4.*PI * np->pdot * dtmp);
131 >                d3 = DOT(vtmp,vtmp);
132 >                d4 = (d3 - d2) / d2;
133 >                                                /* new W-G-M-D model */
134 >                dtmp = exp(-d4/dtmp) * d3 / (PI * d2*d2 * dtmp);
135                                                  /* worth using? */
136                  if (dtmp > FTINY) {
137                          copycolor(ctmp, np->scolor);
138 <                        dtmp *= omega;
138 >                        dtmp *= ldot * omega;
139                          scalecolor(ctmp, dtmp);
140                          addcolor(cval, ctmp);
141                  }
# Line 155 | Line 156 | dirnorm(               /* compute source contribution */
156                   */
157                                                  /* roughness + source */
158                  dtmp = np->alpha2 + omega*(1.0/PI);
159 <                                                /* gaussian */
159 >                                                /* Gaussian */
160                  dtmp = exp((2.*DOT(np->prdir,ldir)-2.)/dtmp)/(PI*dtmp);
161                                                  /* worth using? */
162                  if (dtmp > FTINY) {
# Line 365 | Line 366 | m_normal(                      /* color a ray that hit something normal *
366  
367  
368   static void
369 < gaussamp(                       /* sample gaussian specular */
369 > gaussamp(                       /* sample Gaussian specular */
370          RAY  *r,
371          register NORMDAT  *np
372   )

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines