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.95 by greg, Thu Feb 6 02:17:33 2025 UTC vs.
Revision 2.97 by greg, Fri Jun 20 23:21:33 2025 UTC

# Line 261 | Line 261 | rayparticipate(                        /* compute ray medium participation
261          RAY  *r
262   )
263   {
264 <        SCOLOR  ce, ca;
264 >        COLOR   ce;
265          double  re, ge, be;
266  
267          if (intens(r->cext) <= 1./FHUGE)
# Line 274 | Line 274 | rayparticipate(                        /* compute ray medium participation
274                  ge *= 1. - colval(r->albedo,GRN);
275                  be *= 1. - colval(r->albedo,BLU);
276          }
277 <        setscolor(ce,   re<=FTINY ? 1. : re>92. ? 0. : exp(-re),
277 >        setcolor(ce,    re<=FTINY ? 1. : re>92. ? 0. : exp(-re),
278                          ge<=FTINY ? 1. : ge>92. ? 0. : exp(-ge),
279                          be<=FTINY ? 1. : be>92. ? 0. : exp(-be));
280 <        smultscolor(r->rcol, ce);               /* path extinction */
280 >        smultcolor(r->rcol, ce);                /* path extinction */
281          if (r->crtype & SHADOW || intens(r->albedo) <= FTINY)
282                  return;                         /* no scattering */
283          
284          /* PMAP: indirect inscattering accounted for by volume photons? */
285          if (!volumePhotonMapping) {
286 +                SCOLOR  ca;
287                  setscolor(ca,
288 <                        colval(r->albedo,RED)*colval(ambval,RED)*(1.-scolval(ce,RED)),
289 <                        colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-scolval(ce,GRN)),
290 <                        colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-scolval(ce,BLU)));
291 <                saddscolor(r->rcol, ca);                /* ambient in scattering */
288 >                        colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)),
289 >                        colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)),
290 >                        colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU)));
291 >                saddscolor(r->rcol, ca);        /* ambient in scattering */
292          }
293          
294          srcscatter(r);                          /* source in scattering */
# Line 411 | Line 412 | raycontrib(            /* compute (cumulative) ray contribution
412   )
413   {
414          static int      warnedPM = 0;
415 +        double          re, ge, be;
416 +        SCOLOR          ce;
417  
418          setscolor(rc, 1., 1., 1.);
419 +        re = ge = be = 0.;
420  
421          while (r != NULL && r->crtype&flags) {
422 +                                        /* include this ray coefficient */
423                  smultscolor(rc, r->rcoef);
424 <                                        /* check for participating medium */
420 <                if (bright(r->cext) > FTINY) {
421 <                        double  re = r->rot*colval(r->cext,RED),
422 <                                ge = r->rot*colval(r->cext,GRN),
423 <                                be = r->rot*colval(r->cext,BLU);
424 <                        SCOLOR  ce;
425 <                        setscolor(ce,   re<=FTINY ? 1. : re>92. ? 0. : exp(-re),
426 <                                        ge<=FTINY ? 1. : ge>92. ? 0. : exp(-ge),
427 <                                        be<=FTINY ? 1. : be>92. ? 0. : exp(-be));
428 <                        smultscolor(rc, ce);
429 <                }
424 >                                        /* check participating medium */
425                  if (!warnedPM && bright(r->albedo) > FTINY) {
426                          error(WARNING,
427          "ray contribution calculation does not support participating media");
428                          warnedPM++;
429                  }
430 +                                        /* sum PM extinction */
431 +                re += r->rot*colval(r->cext,RED);
432 +                ge += r->rot*colval(r->cext,GRN);
433 +                be += r->rot*colval(r->cext,BLU);
434 +                                        /* descend the tree */
435                  r = r->parent;
436          }
437 +                                        /* cumulative extinction */
438 +        setscolor(ce,   re<=FTINY ? 1. : re>92. ? 0. : exp(-re),
439 +                        ge<=FTINY ? 1. : ge>92. ? 0. : exp(-ge),
440 +                        be<=FTINY ? 1. : be>92. ? 0. : exp(-be));
441 +        smultscolor(rc, ce);
442   }
443  
444  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines