ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/aniso.c
(Generate patch)

Comparing ray/src/rt/aniso.c (file contents):
Revision 2.56 by greg, Sat Jan 25 18:27:39 2014 UTC vs.
Revision 2.58 by greg, Tue Feb 24 19:39:26 2015 UTC

# Line 14 | Line 14 | static const char RCSid[] = "$Id$";
14   #include  "source.h"
15   #include  "func.h"
16   #include  "random.h"
17 + #include  "pmapmat.h"
18  
19   #ifndef  MAXITER
20   #define  MAXITER        10              /* maximum # specular ray attempts */
# Line 41 | Line 42 | static const char RCSid[] = "$Id$";
42   #define  SP_FLAT        04              /* reflecting surface is flat */
43   #define  SP_RBLT        010             /* reflection below sample threshold */
44   #define  SP_TBLT        020             /* transmission below threshold */
44 #define  SP_BADU        040             /* bad u direction calculation */
45  
46   typedef struct {
47          OBJREC  *mp;            /* material pointer */
# Line 98 | Line 98 | diraniso(              /* compute source contribution */
98                  scalecolor(ctmp, dtmp);
99                  addcolor(cval, ctmp);
100          }
101 <        if (ldot > FTINY && (np->specfl&(SP_REFL|SP_BADU)) == SP_REFL) {
101 >
102 >        if ((ldot < -FTINY) & (np->tdiff > FTINY)) {
103                  /*
104 +                 *  Compute diffuse transmission.
105 +                 */
106 +                copycolor(ctmp, np->mcolor);
107 +                dtmp = -ldot * omega * np->tdiff * (1.0/PI);
108 +                scalecolor(ctmp, dtmp);
109 +                addcolor(cval, ctmp);
110 +        }
111 +
112 +        /* PMAP: skip direct specular refl via ambient bounce if already
113 +         * accounted for in photon map */
114 +        if (ambRayInPmap(np->rp))
115 +                return;
116 +        
117 +        if (ldot > FTINY && np->specfl&SP_REFL) {
118 +                /*
119                   *  Compute specular reflection coefficient using
120                   *  anisotropic Gaussian distribution model.
121                   */
# Line 131 | Line 147 | diraniso(              /* compute source contribution */
147                          addcolor(cval, ctmp);
148                  }
149          }
150 <        if ((ldot < -FTINY) & (np->tdiff > FTINY)) {
150 >        
151 >        if (ldot < -FTINY && np->specfl&SP_TRAN) {
152                  /*
136                 *  Compute diffuse transmission.
137                 */
138                copycolor(ctmp, np->mcolor);
139                dtmp = -ldot * omega * np->tdiff * (1.0/PI);
140                scalecolor(ctmp, dtmp);
141                addcolor(cval, ctmp);
142        }
143        if (ldot < -FTINY && (np->specfl&(SP_TRAN|SP_BADU)) == SP_TRAN) {
144                /*
153                   *  Compute specular transmission.  Specular transmission
154                   *  is always modified by material color.
155                   */
# Line 268 | Line 276 | m_aniso(                       /* shade ray that hit something anisotropic
276  
277          getacoords(&nd);                        /* set up coordinates */
278  
279 <        if (nd.specfl & (SP_REFL|SP_TRAN) && !(nd.specfl & SP_BADU))
279 >        /* PMAP: skip indirect specular via ambient bounce if already accounted
280 >         * for in photon map */
281 >        if (!ambRayInPmap(r) && nd.specfl & (SP_REFL|SP_TRAN))
282                  agaussamp(&nd);
283  
284          if (nd.rdiff > FTINY) {         /* ambient from this side */
# Line 279 | Line 289 | m_aniso(                       /* shade ray that hit something anisotropic
289                  multambient(ctmp, r, nd.pnorm);
290                  addcolor(r->rcol, ctmp);        /* add to returned color */
291          }
292 +        
293          if (nd.tdiff > FTINY) {         /* ambient from other side */
294                  FVECT  bnorm;
295  
# Line 301 | Line 312 | m_aniso(                       /* shade ray that hit something anisotropic
312          return(1);
313   }
314  
304
315   static void
316   getacoords(             /* set up coordinate system */
317          ANISODAT  *np
# Line 315 | Line 325 | getacoords(            /* set up coordinate system */
325          errno = 0;
326          for (i = 0; i < 3; i++)
327                  np->u[i] = evalue(mf->ep[i]);
328 <        if ((errno == EDOM) | (errno == ERANGE)) {
329 <                objerror(np->mp, WARNING, "compute error");
320 <                np->specfl |= SP_BADU;
321 <                return;
322 <        }
328 >        if ((errno == EDOM) | (errno == ERANGE))
329 >                np->u[0] = np->u[1] = np->u[2] = 0.0;
330          if (mf->fxp != &unitxf)
331                  multv3(np->u, np->u, mf->fxp->xfm);
332          fcross(np->v, np->pnorm, np->u);
333          if (normalize(np->v) == 0.0) {
334 <                objerror(np->mp, WARNING, "illegal orientation vector");
335 <                np->specfl |= SP_BADU;
336 <                return;
337 <        }
338 <        fcross(np->u, np->v, np->pnorm);
334 >                if (fabs(np->u_alpha - np->v_alpha) > 0.001)
335 >                        objerror(np->mp, WARNING, "illegal orientation vector");
336 >                getperpendicular(np->u, np->pnorm);     /* punting */
337 >                fcross(np->v, np->pnorm, np->u);
338 >                np->u_alpha = np->v_alpha = sqrt( 0.5 *
339 >                        (np->u_alpha*np->u_alpha + np->v_alpha*np->v_alpha) );
340 >        } else
341 >                fcross(np->u, np->v, np->pnorm);
342   }
343  
344  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines