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.55 by greg, Sun Jul 29 21:56:16 2012 UTC vs.
Revision 2.61 by greg, Wed Sep 2 18:59:01 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 +        if (ambRayInPmap(np->rp))
113 +                return;         /* specular accounted for in photon map */
114 +
115 +        if (ldot > FTINY && np->specfl&SP_REFL) {
116 +                /*
117                   *  Compute specular reflection coefficient using
118                   *  anisotropic Gaussian distribution model.
119                   */
# Line 131 | Line 145 | diraniso(              /* compute source contribution */
145                          addcolor(cval, ctmp);
146                  }
147          }
148 <        if ((ldot < -FTINY) & (np->tdiff > FTINY)) {
148 >        
149 >        if (ldot < -FTINY && np->specfl&SP_TRAN) {
150                  /*
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                /*
151                   *  Compute specular transmission.  Specular transmission
152                   *  is always modified by material color.
153                   */
# Line 194 | Line 200 | m_aniso(                       /* shade ray that hit something anisotropic
200                  objerror(m, USER, "bad number of real arguments");
201                                                  /* check for back side */
202          if (r->rod < 0.0) {
203 <                if (!backvis && m->otype != MAT_TRANS2) {
203 >                if (!backvis) {
204                          raytrans(r);
205                          return(1);
206                  }
# Line 268 | Line 274 | m_aniso(                       /* shade ray that hit something anisotropic
274  
275          getacoords(&nd);                        /* set up coordinates */
276  
277 <        if (nd.specfl & (SP_REFL|SP_TRAN) && !(nd.specfl & SP_BADU))
277 >        if (nd.specfl & (SP_REFL|SP_TRAN))
278                  agaussamp(&nd);
279  
280          if (nd.rdiff > FTINY) {         /* ambient from this side */
# Line 279 | Line 285 | m_aniso(                       /* shade ray that hit something anisotropic
285                  multambient(ctmp, r, nd.pnorm);
286                  addcolor(r->rcol, ctmp);        /* add to returned color */
287          }
288 +        
289          if (nd.tdiff > FTINY) {         /* ambient from other side */
290                  FVECT  bnorm;
291  
# Line 301 | Line 308 | m_aniso(                       /* shade ray that hit something anisotropic
308          return(1);
309   }
310  
304
311   static void
312   getacoords(             /* set up coordinate system */
313          ANISODAT  *np
# Line 315 | Line 321 | getacoords(            /* set up coordinate system */
321          errno = 0;
322          for (i = 0; i < 3; i++)
323                  np->u[i] = evalue(mf->ep[i]);
324 <        if ((errno == EDOM) | (errno == ERANGE)) {
325 <                objerror(np->mp, WARNING, "compute error");
320 <                np->specfl |= SP_BADU;
321 <                return;
322 <        }
324 >        if ((errno == EDOM) | (errno == ERANGE))
325 >                np->u[0] = np->u[1] = np->u[2] = 0.0;
326          if (mf->fxp != &unitxf)
327                  multv3(np->u, np->u, mf->fxp->xfm);
328          fcross(np->v, np->pnorm, np->u);
329          if (normalize(np->v) == 0.0) {
330 <                objerror(np->mp, WARNING, "illegal orientation vector");
331 <                np->specfl |= SP_BADU;
332 <                return;
333 <        }
334 <        fcross(np->u, np->v, np->pnorm);
330 >                if (fabs(np->u_alpha - np->v_alpha) > 0.001)
331 >                        objerror(np->mp, WARNING, "illegal orientation vector");
332 >                getperpendicular(np->u, np->pnorm, 1);  /* punting */
333 >                fcross(np->v, np->pnorm, np->u);
334 >                np->u_alpha = np->v_alpha = sqrt( 0.5 *
335 >                        (np->u_alpha*np->u_alpha + np->v_alpha*np->v_alpha) );
336 >        } else
337 >                fcross(np->u, np->v, np->pnorm);
338   }
339  
340  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines