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.3 by greg, Sat Jan 4 23:36:42 1992 UTC vs.
Revision 2.4 by greg, Tue Jan 14 15:33:08 1992 UTC

# Line 279 | Line 279 | register NORMDAT  *np;
279          FVECT  u, v, h;
280          double  rv[2];
281          double  d, sinp, cosp;
282 <        int  confuse;
282 >        int  ntries;
283          register int  i;
284                                          /* set up sample coordinates */
285          v[0] = v[1] = v[2] = 0.0;
# Line 293 | Line 293 | register NORMDAT  *np;
293                                          /* compute reflection */
294          if (np->specfl & SP_REFL &&
295                          rayorigin(&sr, r, SPECULAR, np->rspec) == 0) {
296                confuse = 0;
296                  dimlist[ndims++] = (int)np->mp;
297 <        refagain:
298 <                dimlist[ndims] = confuse += 3601;
299 <                d = urand(ilhash(dimlist,ndims+1)+samplendx);
300 <                multisamp(rv, 2, d);
301 <                d = 2.0*PI * rv[0];
302 <                cosp = cos(d);
303 <                sinp = sin(d);
304 <                if (rv[1] <= FTINY)
305 <                        d = 1.0;
306 <                else
307 <                        d = sqrt( np->alpha2 * -log(rv[1]) );
308 <                for (i = 0; i < 3; i++)
309 <                        h[i] = np->pnorm[i] + d*(cosp*u[i] + sinp*v[i]);
310 <                d = -2.0 * DOT(h, r->rdir) / (1.0 + d*d);
311 <                for (i = 0; i < 3; i++)
312 <                        sr.rdir[i] = r->rdir[i] + d*h[i];
313 <                if (DOT(sr.rdir, r->ron) <= FTINY)      /* oops! */
314 <                        goto refagain;
315 <                rayvalue(&sr);
316 <                multcolor(sr.rcol, np->scolor);
317 <                addcolor(r->rcol, sr.rcol);
297 >                for (ntries = 0; ntries < 10; ntries++) {
298 >                        dimlist[ndims] = ntries * 8912;
299 >                        d = urand(ilhash(dimlist,ndims+1)+samplendx);
300 >                        multisamp(rv, 2, d);
301 >                        d = 2.0*PI * rv[0];
302 >                        cosp = cos(d);
303 >                        sinp = sin(d);
304 >                        if (rv[1] <= FTINY)
305 >                                d = 1.0;
306 >                        else
307 >                                d = sqrt( np->alpha2 * -log(rv[1]) );
308 >                        for (i = 0; i < 3; i++)
309 >                                h[i] = np->pnorm[i] + d*(cosp*u[i] + sinp*v[i]);
310 >                        d = -2.0 * DOT(h, r->rdir) / (1.0 + d*d);
311 >                        for (i = 0; i < 3; i++)
312 >                                sr.rdir[i] = r->rdir[i] + d*h[i];
313 >                        if (DOT(sr.rdir, r->ron) > FTINY) {
314 >                                rayvalue(&sr);
315 >                                multcolor(sr.rcol, np->scolor);
316 >                                addcolor(r->rcol, sr.rcol);
317 >                                break;
318 >                        }
319 >                }
320                  ndims--;
321          }
322                                          /* compute transmission */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines