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.22 by greg, Wed Dec 6 12:07:50 1995 UTC vs.
Revision 2.23 by greg, Fri Dec 8 18:49:09 1995 UTC

# Line 24 | Line 24 | extern CUBE  thescene;                 /* our scene */
24   extern int  maxdepth;                   /* maximum recursion depth */
25   extern double  minweight;               /* minimum ray weight */
26   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 */
31 + extern double  seccg;                   /* global scattering eccentricity */
32 + extern double  ssampdist;               /* scatter sampling distance */
33 +
34   unsigned long  raynum = 0;              /* next unique ray number */
35   unsigned long  nrays = 0;               /* number of calls to localhit */
36  
# Line 55 | Line 61 | double  rw;
61                  r->rsrc = -1;
62                  r->clipset = NULL;
63                  r->revf = raytrace;
64 +                copycolor(r->cext, cextinction);
65 +                r->albedo = salbedo;
66 +                r->gecc = seccg;
67 +                r->slights = NULL;
68          } else {                                /* spawned ray */
69                  r->rlvl = ro->rlvl;
70                  if (rt & RAYREFL) {
# Line 68 | Line 78 | double  rw;
78                          r->rmax = ro->rmax <= FTINY ? 0.0 : ro->rmax - ro->rot;
79                  }
80                  r->revf = ro->revf;
81 +                copycolor(r->cext, ro->cext);
82 +                r->albedo = ro->albedo;
83 +                r->gecc = ro->gecc;
84 +                r->slights = ro->slights;
85                  r->rweight = ro->rweight * rw;
86                  r->crtype = ro->crtype | (r->rtype = rt);
87                  VCOPY(r->rorg, ro->rop);
# Line 98 | Line 112 | RAY  *r;
112          int  gotmat;
113  
114          if (localhit(r, &thescene))
115 <                gotmat = raycont(r);
115 >                gotmat = raycont(r);    /* hit local surface, evaluate */
116          else if (r->ro == &Aftplane) {
117 <                r->ro = NULL;
117 >                r->ro = NULL;           /* hit aft clipping plane */
118                  r->rot = FHUGE;
119          } else if (sourcehit(r))
120 <                gotmat = rayshade(r, r->ro->omod);
120 >                gotmat = rayshade(r, r->ro->omod);      /* distant source */
121  
122          if (r->ro != NULL && !gotmat)
123                  objerror(r->ro, USER, "material not found");
124  
125 +        rayparticipate(r);              /* for participating medium */
126 +
127          if (trace != NULL)
128                  (*trace)(r);            /* trace execution */
129   }
# Line 173 | Line 189 | int  mod;
189          }
190          depth--;
191          return(gotmat);
192 + }
193 +
194 +
195 + rayparticipate(r)                       /* compute ray medium participation */
196 + register RAY  *r;
197 + {
198 +        COLOR   ce, ca;
199 +        double  dist;
200 +        double  re, ge, be;
201 +
202 +        if (intens(r->cext) <= 1./FHUGE)
203 +                return;                         /* no medium */
204 +        if ((dist = r->rot) >= FHUGE)
205 +                dist = 2.*thescene.cusize;      /* what to use for infinity? */
206 +        if (r->crtype & SHADOW)
207 +                dist *= 1. - salbedo;           /* no scattering for sources */
208 +        if (dist <= FTINY)
209 +                return;                         /* no effective ray travel */
210 +        re = dist*colval(r->cext,RED);
211 +        ge = dist*colval(r->cext,GRN);
212 +        be = dist*colval(r->cext,BLU);
213 +        setcolor(ce,    re>92. ? 0. : exp(-re),
214 +                        ge>92. ? 0. : exp(-ge),
215 +                        be>92. ? 0. : exp(-be));
216 +        multcolor(r->rcol, ce);                 /* path absorption */
217 +        if (r->albedo <= FTINY || r->crtype & SHADOW)
218 +                return;                         /* no scattering */
219 +        setcolor(ca,    salbedo*colval(ambval,RED)*(1.-colval(ce,RED)),
220 +                        salbedo*colval(ambval,GRN)*(1.-colval(ce,GRN)),
221 +                        salbedo*colval(ambval,BLU)*(1.-colval(ce,BLU)));
222 +        addcolor(r->rcol, ca);                  /* ambient in scattering */
223 +        srcscatter(r);                          /* source in scattering */
224   }
225  
226  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines