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.24 by greg, Thu Mar 21 15:33:05 1996 UTC vs.
Revision 2.29 by gregl, Tue Dec 23 18:25:15 1997 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1995 Regents of the University of California */
1 > /* Copyright (c) 1996 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 27 | Line 27 | extern int  do_irrad;                  /* compute irradiance? */
27   extern COLOR  ambval;                   /* ambient value */
28  
29   extern COLOR  cextinction;              /* global extinction coefficient */
30 < extern double  salbedo;                 /* global scattering albedo */
30 > extern COLOR  salbedo;                  /* global scattering albedo */
31   extern double  seccg;                   /* global scattering eccentricity */
32   extern double  ssampdist;               /* scatter sampling distance */
33  
# Line 62 | Line 62 | double  rw;
62                  r->clipset = NULL;
63                  r->revf = raytrace;
64                  copycolor(r->cext, cextinction);
65 <                r->albedo = salbedo;
65 >                copycolor(r->albedo, salbedo);
66                  r->gecc = seccg;
67                  r->slights = NULL;
68          } else {                                /* spawned ray */
# Line 79 | Line 79 | double  rw;
79                  }
80                  r->revf = ro->revf;
81                  copycolor(r->cext, ro->cext);
82 <                r->albedo = ro->albedo;
82 >                copycolor(r->albedo, ro->albedo);
83                  r->gecc = ro->gecc;
84                  r->slights = ro->slights;
85                  r->rweight = ro->rweight * rw;
# Line 96 | Line 96 | register RAY  *r;
96   {
97          r->rno = raynum++;
98          r->newcset = r->clipset;
99 +        r->robj = OVOID;
100          r->ro = NULL;
101 <        r->rot = FHUGE;
101 >        r->rt = r->rot = FHUGE;
102          r->pert[0] = r->pert[1] = r->pert[2] = 0.0;
103          setcolor(r->pcol, 1.0, 1.0, 1.0);
104          setcolor(r->rcol, 0.0, 0.0, 0.0);
104        r->rt = 0.0;
105   }
106  
107  
# Line 189 | Line 189 | rayparticipate(r)                      /* compute ray medium participatio
189   register RAY  *r;
190   {
191          COLOR   ce, ca;
192        double  dist;
192          double  re, ge, be;
193  
194          if (intens(r->cext) <= 1./FHUGE)
195                  return;                         /* no medium */
196 <        if ((dist = r->rot) >= FHUGE)
197 <                dist = 2.*thescene.cusize;      /* what to use for infinity? */
198 <        if (r->crtype & SHADOW)
199 <                dist *= 1. - salbedo;           /* no scattering for sources */
200 <        if (dist <= FTINY)
201 <                return;                         /* no effective ray travel */
202 <        re = dist*colval(r->cext,RED);
203 <        ge = dist*colval(r->cext,GRN);
204 <        be = dist*colval(r->cext,BLU);
205 <        setcolor(ce,    re>92. ? 0. : exp(-re),
206 <                        ge>92. ? 0. : exp(-ge),
208 <                        be>92. ? 0. : exp(-be));
196 >        re = r->rot*colval(r->cext,RED);
197 >        ge = r->rot*colval(r->cext,GRN);
198 >        be = r->rot*colval(r->cext,BLU);
199 >        if (r->crtype & SHADOW) {               /* no scattering for sources */
200 >                re *= 1. - colval(r->albedo,RED);
201 >                ge *= 1. - colval(r->albedo,GRN);
202 >                be *= 1. - colval(r->albedo,BLU);
203 >        }
204 >        setcolor(ce,    re<=0. ? 1. : re>92. ? 0. : exp(-re),
205 >                        ge<=0. ? 1. : ge>92. ? 0. : exp(-ge),
206 >                        be<=0. ? 1. : be>92. ? 0. : exp(-be));
207          multcolor(r->rcol, ce);                 /* path absorption */
208 <        if (r->albedo <= FTINY || r->crtype & SHADOW)
208 >        if (r->crtype & SHADOW || intens(r->albedo) <= FTINY)
209                  return;                         /* no scattering */
210 <        setcolor(ca,    salbedo*colval(ambval,RED)*(1.-colval(ce,RED)),
211 <                        salbedo*colval(ambval,GRN)*(1.-colval(ce,GRN)),
212 <                        salbedo*colval(ambval,BLU)*(1.-colval(ce,BLU)));
210 >        setcolor(ca,
211 >                colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)),
212 >                colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)),
213 >                colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU)));
214          addcolor(r->rcol, ca);                  /* ambient in scattering */
215          srcscatter(r);                          /* source in scattering */
216   }
# Line 555 | Line 554 | OBJECT  *cxs;
554          checkset(oset, cxs);                    /* eliminate double-checking */
555          for (i = oset[0]; i > 0; i--) {
556                  o = objptr(oset[i]);
557 <                (*ofun[o->otype].funp)(o, r);
557 >                if ((*ofun[o->otype].funp)(o, r))
558 >                        r->robj = oset[i];
559          }
560          if (r->ro == NULL)
561                  return(0);                      /* no scores yet */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines