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.5 by greg, Tue Jan 14 16:16:45 1992 UTC vs.
Revision 2.7 by greg, Wed Jan 15 11:41:44 1992 UTC

# Line 192 | Line 192 | register RAY  *r;
192                          colval(nd.scolor,i) += (1.0-colval(nd.scolor,i))*dtmp;
193                  nd.rspec += (1.0-nd.rspec)*dtmp;
194                                                  /* check threshold */
195 <                if (nd.rspec <= specthresh+FTINY)
195 >                if (specthresh > FTINY &&
196 >                                ((specthresh >= 1.-FTINY ||
197 >                                specthresh + (.1 - .2*urand(8199+samplendx))
198 >                                        > nd.rspec)))
199                          nd.specfl |= SP_RBLT;
200                                                  /* compute reflected ray */
201                  for (i = 0; i < 3; i++)
202                          nd.vrefl[i] = r->rdir[i] + 2.0*nd.pdot*nd.pnorm[i];
203 +                if (DOT(nd.vrefl, r->ron) <= FTINY)     /* penetration? */
204 +                        for (i = 0; i < 3; i++)         /* safety measure */
205 +                                nd.vrefl[i] = r->rdir[i] + 2.*r->rod*r->ron[i];
206  
207                  if (!(r->crtype & SHADOW) && nd.specfl & SP_PURE) {
208                          RAY  lr;
# Line 216 | Line 222 | register RAY  *r;
222                  if (nd.tspec > FTINY) {
223                          nd.specfl |= SP_TRAN;
224                                                          /* check threshold */
225 <                        if (nd.tspec <= specthresh+FTINY)
225 >                        if (specthresh > FTINY &&
226 >                                        ((specthresh >= 1.-FTINY ||
227 >                                        specthresh +
228 >                                            (.1 - .2*urand(7241+samplendx))
229 >                                                > nd.tspec)))
230                                  nd.specfl |= SP_TBLT;
231                          if (r->crtype & SHADOW ||
232                                          DOT(r->pert,r->pert) <= FTINY*FTINY) {
# Line 226 | Line 236 | register RAY  *r;
236                                  for (i = 0; i < 3; i++)         /* perturb */
237                                          nd.prdir[i] = r->rdir[i] -
238                                                          .75*r->pert[i];
239 <                                normalize(nd.prdir);
239 >                                if (DOT(nd.prdir, r->ron) < -FTINY)
240 >                                        normalize(nd.prdir);    /* OK */
241 >                                else
242 >                                        VCOPY(nd.prdir, r->rdir);
243                          }
244                  }
245          } else
# Line 296 | Line 309 | register NORMDAT  *np;
309          FVECT  u, v, h;
310          double  rv[2];
311          double  d, sinp, cosp;
299        int  ntries;
312          register int  i;
313                                          /* set up sample coordinates */
314          v[0] = v[1] = v[2] = 0.0;
# Line 311 | Line 323 | register NORMDAT  *np;
323          if ((np->specfl & (SP_REFL|SP_RBLT)) == SP_REFL &&
324                          rayorigin(&sr, r, SPECULAR, np->rspec) == 0) {
325                  dimlist[ndims++] = (int)np->mp;
326 <                for (ntries = 0; ntries < 10; ntries++) {
327 <                        dimlist[ndims] = ntries * 8912;
328 <                        d = urand(ilhash(dimlist,ndims+1)+samplendx);
329 <                        multisamp(rv, 2, d);
330 <                        d = 2.0*PI * rv[0];
331 <                        cosp = cos(d);
332 <                        sinp = sin(d);
333 <                        rv[1] = 1.0 - specjitter*rv[1];
334 <                        if (rv[1] <= FTINY)
335 <                                d = 1.0;
336 <                        else
337 <                                d = sqrt( np->alpha2 * -log(rv[1]) );
338 <                        for (i = 0; i < 3; i++)
339 <                                h[i] = np->pnorm[i] + d*(cosp*u[i] + sinp*v[i]);
340 <                        d = -2.0 * DOT(h, r->rdir) / (1.0 + d*d);
341 <                        for (i = 0; i < 3; i++)
342 <                                sr.rdir[i] = r->rdir[i] + d*h[i];
343 <                        if (DOT(sr.rdir, r->ron) > FTINY) {
344 <                                rayvalue(&sr);
345 <                                multcolor(sr.rcol, np->scolor);
334 <                                addcolor(r->rcol, sr.rcol);
335 <                                break;
336 <                        }
337 <                }
326 >                d = urand(ilhash(dimlist,ndims)+samplendx);
327 >                multisamp(rv, 2, d);
328 >                d = 2.0*PI * rv[0];
329 >                cosp = cos(d);
330 >                sinp = sin(d);
331 >                rv[1] = 1.0 - specjitter*rv[1];
332 >                if (rv[1] <= FTINY)
333 >                        d = 1.0;
334 >                else
335 >                        d = sqrt( np->alpha2 * -log(rv[1]) );
336 >                for (i = 0; i < 3; i++)
337 >                        h[i] = np->pnorm[i] + d*(cosp*u[i] + sinp*v[i]);
338 >                d = -2.0 * DOT(h, r->rdir) / (1.0 + d*d);
339 >                for (i = 0; i < 3; i++)
340 >                        sr.rdir[i] = r->rdir[i] + d*h[i];
341 >                if (DOT(sr.rdir, r->ron) <= FTINY)
342 >                        VCOPY(sr.rdir, np->vrefl);      /* jitter no good */
343 >                rayvalue(&sr);
344 >                multcolor(sr.rcol, np->scolor);
345 >                addcolor(r->rcol, sr.rcol);
346                  ndims--;
347          }
348                                          /* compute transmission */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines