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.4 by greg, Thu Dec 4 05:26:28 2014 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines