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

Comparing ray/src/rt/ashikhmin.c (file contents):
Revision 2.3 by greg, Wed Aug 7 05:10:09 2013 UTC vs.
Revision 2.6 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 32 | Line 33 | static const char RCSid[] = "$Id$";
33   #define  SPA_REFL       01              /* has reflected specular component */
34   #define  SPA_FLAT       02              /* reflecting surface is flat */
35   #define  SPA_RBLT       010             /* reflection below sample threshold */
35 #define  SPA_BADU       020             /* bad u direction calculation */
36  
37   typedef struct {
38          OBJREC  *mp;            /* material pointer */
# Line 93 | Line 93 | dirashik(              /* compute source contribution */
93          scalecolor(ctmp, dtmp);        
94          addcolor(cval, ctmp);
95  
96 <        if ((np->specfl & (SPA_REFL|SPA_BADU)) != SPA_REFL)
96 >        if (!(np->specfl & SPA_REFL) || ambRayInPmap(np->rp))
97                  return;
98          /*
99           *  Compute specular reflection coefficient
# Line 209 | Line 209 | getacoords_as(         /* set up coordinate system */
209          errno = 0;
210          for (i = 0; i < 3; i++)
211                  np->u[i] = evalue(mf->ep[i]);
212 <        if ((errno == EDOM) | (errno == ERANGE)) {
213 <                objerror(np->mp, WARNING, "compute error");
214 <                np->specfl |= SPA_BADU;
215 <                return;
216 <        }
212 >        if ((errno == EDOM) | (errno == ERANGE))
213 >                np->u[0] = np->u[1] = np->u[2] = 0.0;
214          if (mf->fxp != &unitxf)
215                  multv3(np->u, np->u, mf->fxp->xfm);
216          fcross(np->v, np->pnorm, np->u);
217          if (normalize(np->v) == 0.0) {
218 <                objerror(np->mp, WARNING, "illegal orientation vector");
219 <                np->specfl |= SPA_BADU;
220 <                return;
221 <        }
222 <        fcross(np->u, np->v, np->pnorm);
218 >                if (fabs(np->u_power - np->v_power) > 0.1)
219 >                        objerror(np->mp, WARNING, "bad orientation vector");
220 >                getperpendicular(np->u, np->pnorm, 1);  /* punting */
221 >                fcross(np->v, np->pnorm, np->u);
222 >                np->u_power = np->v_power =
223 >                        2./(1./(np->u_power+1e-5) + 1./(np->v_power+1e-5));
224 >        } else
225 >                fcross(np->u, np->v, np->pnorm);
226   }
227  
228  
# Line 238 | Line 238 | ashiksamp(             /* sample anisotropic Ashikhmin-Shirley sp
238          int  maxiter, ntrials, nstarget, nstaken;
239          int  i;
240  
241 <        if (np->specfl & SPA_BADU ||
242 <                        rayorigin(&sr, SPECULAR, np->rp, np->scolor) < 0)
241 >        if (rayorigin(&sr, SPECULAR, np->rp, np->scolor) < 0)
242                  return;
243  
244          nstarget = 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines