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.90 by greg, Fri Nov 15 20:47:42 2024 UTC vs.
Revision 2.97 by greg, Fri Jun 20 23:21:33 2025 UTC

# Line 61 | Line 61 | rayorigin(             /* start new ray from old one */
61                  r->rweight = rw;
62                  r->crtype = r->rtype = rt;
63                  r->rsrc = -1;
64 #ifdef SSKIPOPT
65                r->scorr = 1.f;
66 #endif
64                  r->clipset = NULL;
65                  r->revf = raytrace;
66                  copycolor(r->cext, cextinction);
# Line 77 | Line 74 | rayorigin(             /* start new ray from old one */
74                  }
75                  r->rlvl = ro->rlvl;
76                  r->rsrc = ro->rsrc;
80 #ifdef SSKIPOPT
81                r->scorr = ro->scorr;
82 #endif
77                  if (rt & RAYREFL) {
78                          r->rlvl++;
79                          if (r->rsrc >= 0)       /* malfunctioning material? */
# Line 219 | Line 213 | raytirrad(                     /* irradiance hack */
213          RAY     *r
214   )
215   {
216 <        if (ofun[m->otype].flags & (T_M|T_X) && m->otype != MAT_CLIP) {
217 <                if (istransp(m->otype) || isBSDFproxy(m)) {
216 >        if (m->otype != MAT_CLIP && ismaterial(m->otype)) {
217 >                if (istransp(m) || isBSDFproxy(m)) {
218                          raytrans(r);
219                          return(1);
220                  }
# Line 267 | 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 280 | 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.-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 */
291 >                saddscolor(r->rcol, ca);        /* ambient in scattering */
292          }
293          
294          srcscatter(r);                          /* source in scattering */
# Line 417 | 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 */
425 <                if (!warnedPM && (bright(r->cext) > FTINY) |
427 <                                (bright(r->albedo) > FTINY)) {
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  
# Line 461 | Line 469 | raynormal(             /* compute perturbed normal for ray */
469                  return(r->rod);
470          }
471          newdot = -DOT(norm, r->rdir);
472 <        if ((newdot > 0.0) != (r->rod > 0.0)) {         /* fix orientation */
472 >        if ((newdot > 0.0) ^ (r->rod > 0.0)) {          /* fix orientation */
473                  for (i = 0; i < 3; i++)
474                          norm[i] += 2.0*newdot*r->rdir[i];
475                  newdot = -newdot;
# Line 550 | Line 558 | rayreject(             /* check if candidate hit is worse than cu
558                          return(1);      /* old has material, new does not */
559          } else if (mray == NULL) {
560                  return(0);              /* new has material, old does not */
561 <        } else if (istransp(mnew->otype)) {
562 <                if (!istransp(mray->otype))
561 >        } else if (istransp(mnew)) {
562 >                if (!istransp(mray))
563                          return(1);      /* new is transparent, old is not */
564 <        } else if (istransp(mray->otype)) {
564 >        } else if (istransp(mray)) {
565                  return(0);              /* old is transparent, new is not */
566          }
567          if (rod <= 0) {                 /* check which side we hit */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines