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

Comparing ray/src/rt/raytrace.c (file contents):
Revision 2.51 by greg, Tue May 31 18:01:09 2005 UTC vs.
Revision 2.58 by schorsch, Wed Jun 7 17:52:04 2006 UTC

# Line 23 | Line 23 | unsigned long  nrays = 0;              /* number of calls to local
23   static RREAL  Lambfa[5] = {PI, PI, PI, 0.0, 0.0};
24   OBJREC  Lamb = {
25          OVOID, MAT_PLASTIC, "Lambertian",
26 <        {0, 5, NULL, Lambfa}, NULL,
26 >        {NULL, Lambfa, 0, 5}, NULL
27   };                                      /* a Lambertian surface */
28  
29   OBJREC  Aftplane;                       /* aft clipping plane object */
# Line 93 | Line 93 | rayorigin(             /* start new ray from old one */
93                                  colval(ro->cext,RED) : colval(ro->cext,GRN);
94                  if (colval(ro->cext,BLU) < re) re = colval(ro->cext,BLU);
95                  re *= ro->rot;
96 <                if (re > .1)
97 <                        r->rweight *= exp(-re);
96 >                if (re > 0.1) {
97 >                        if (re > 92.) {
98 >                                r->rweight = 0.0;
99 >                        } else {
100 >                                r->rweight *= exp(-re);
101 >                        }
102 >                }
103          }
104          rayclear(r);
105 +        if (r->rweight <= 0.0)                  /* check for expiration */
106 +                return(-1);
107 +        if (r->crtype & SHADOW)                 /* shadow commitment */
108 +                return(0);
109          if (maxdepth <= 0 && rc != NULL) {      /* Russian roulette */
110                  if (minweight <= 0.0)
111                          error(USER, "zero ray weight in Russian roulette");
# Line 104 | Line 113 | rayorigin(             /* start new ray from old one */
113                          return(-1);             /* upper reflection limit */
114                  if (r->rweight >= minweight)
115                          return(0);
116 <                if (frandom() < r->rweight/minweight)
116 >                if (frandom() > r->rweight/minweight)
117                          return(-1);
118                  rw = minweight/r->rweight;      /* promote survivor */
119                  scalecolor(r->rcoef, rw);
120                  r->rweight = minweight;
121                  return(0);
122          }
123 <        return(r->rlvl <= maxdepth && r->rweight >= minweight ? 0 : -1);
123 >        return(r->rlvl <= abs(maxdepth) && r->rweight >= minweight ? 0 : -1);
124   }
125  
126  
# Line 294 | Line 303 | raymixture(            /* mix modifiers */
303          foremat = backmat = 0;
304                                          /* foreground */
305          fr = *r;
306 <        if (coef > FTINY)
306 >        if (coef > FTINY) {
307 >                scalecolor(fr.rcoef, coef);
308                  foremat = rayshade(&fr, fore);
309 +        }
310                                          /* background */
311          br = *r;
312 <        if (coef < 1.0-FTINY)
312 >        if (coef < 1.0-FTINY) {
313 >                scalecolor(br.rcoef, 1.0-coef);
314                  backmat = rayshade(&br, back);
315 +        }
316                                          /* check for transparency */
317          if (backmat ^ foremat) {
318                  if (backmat && coef > FTINY)
# Line 346 | Line 359 | raydist(               /* compute (cumulative) ray distance */
359  
360   extern void
361   raycontrib(             /* compute (cumulative) ray contribution */
362 <        COLOR  rc,
362 >        double  rc[3],
363          const RAY  *r,
364          int  flags
365   )
366   {
367 <        COLOR   eext, ext1;
368 <        
356 <        setcolor(eext, 0., 0., 0.);
357 <        setcolor(rc, 1., 1., 1.);
367 >        double  eext[3];
368 >        int     i;
369  
370 +        eext[0] = eext[1] = eext[2] = 0.;
371 +        rc[0] = rc[1] = rc[2] = 1.;
372 +
373          while (r != NULL && r->crtype&flags) {
374 <                multcolor(rc, r->rcoef);
375 <                copycolor(ext1, r->cext);
376 <                scalecolor(ext1, r->rot);
377 <                addcolor(eext, ext1);
374 >                for (i = 3; i--; ) {
375 >                        rc[i] *= colval(r->rcoef,i);
376 >                        eext[i] += r->rot * colval(r->cext,i);
377 >                }
378                  r = r->parent;
379          }
380 <        if (intens(eext) > FTINY) {
381 <                setcolor(ext1,  exp(-colval(eext,RED)),
382 <                                exp(-colval(eext,GRN)),
369 <                                exp(-colval(eext,BLU)));
370 <                multcolor(rc, ext1);
371 <        }
380 >        for (i = 3; i--; )
381 >                rc[i] *= (eext[i] <= FTINY) ? 1. :
382 >                                (eext[i] > 92.) ? 0. : exp(-eext[i]);
383   }
384  
385  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines