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.89 by greg, Wed Jul 31 22:29:18 2024 UTC vs.
Revision 2.96 by greg, Fri Feb 7 16:32:56 2025 UTC

# Line 73 | Line 73 | rayorigin(             /* start new ray from old one */
73                          return(-1);             /* illegal continuation */
74                  }
75                  r->rlvl = ro->rlvl;
76 +                r->rsrc = ro->rsrc;
77                  if (rt & RAYREFL) {
78                          r->rlvl++;
79 <                        r->rsrc = -1;
79 >                        if (r->rsrc >= 0)       /* malfunctioning material? */
80 >                                r->rsrc = -1;
81                          r->clipset = ro->clipset;
82                          r->rmax = 0.0;
83                  } else {
82                        r->rsrc = ro->rsrc;
84                          r->clipset = ro->newcset;
85 <                        r->rmax = ro->rmax <= FTINY ? 0.0 : ro->rmax - ro->rot;
85 >                        r->rmax = (ro->rmax > FTINY)*(ro->rmax - ro->rot);
86                  }
87                  r->revf = ro->revf;
88                  copycolor(r->cext, ro->cext);
# Line 212 | 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 283 | Line 284 | rayparticipate(                        /* compute ray medium participation
284          /* PMAP: indirect inscattering accounted for by volume photons? */
285          if (!volumePhotonMapping) {
286                  setscolor(ca,
287 <                        colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)),
288 <                        colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)),
289 <                        colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU)));
287 >                        colval(r->albedo,RED)*colval(ambval,RED)*(1.-scolval(ce,RED)),
288 >                        colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-scolval(ce,GRN)),
289 >                        colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-scolval(ce,BLU)));
290                  saddscolor(r->rcol, ca);                /* ambient in scattering */
291          }
292          
# Line 410 | Line 411 | raycontrib(            /* compute (cumulative) ray contribution
411   )
412   {
413          static int      warnedPM = 0;
414 +        double          re, ge, be;
415 +        SCOLOR          ce;
416  
417          setscolor(rc, 1., 1., 1.);
418 +        re = ge = be = 0.;
419  
420          while (r != NULL && r->crtype&flags) {
421 +                                        /* include this ray coefficient */
422                  smultscolor(rc, r->rcoef);
423 <                                        /* check for participating medium */
424 <                if (!warnedPM && (bright(r->cext) > FTINY) |
420 <                                (bright(r->albedo) > FTINY)) {
423 >                                        /* check participating medium */
424 >                if (!warnedPM && bright(r->albedo) > FTINY) {
425                          error(WARNING,
426          "ray contribution calculation does not support participating media");
427                          warnedPM++;
428                  }
429 +                                        /* sum PM extinction */
430 +                re += r->rot*colval(r->cext,RED);
431 +                ge += r->rot*colval(r->cext,GRN);
432 +                be += r->rot*colval(r->cext,BLU);
433 +                                        /* descend the tree */
434                  r = r->parent;
435          }
436 +                                        /* cumulative extinction */
437 +        setscolor(ce,   re<=FTINY ? 1. : re>92. ? 0. : exp(-re),
438 +                        ge<=FTINY ? 1. : ge>92. ? 0. : exp(-ge),
439 +                        be<=FTINY ? 1. : be>92. ? 0. : exp(-be));
440 +        smultscolor(rc, ce);
441   }
442  
443  
# Line 454 | Line 468 | raynormal(             /* compute perturbed normal for ray */
468                  return(r->rod);
469          }
470          newdot = -DOT(norm, r->rdir);
471 <        if ((newdot > 0.0) != (r->rod > 0.0)) {         /* fix orientation */
471 >        if ((newdot > 0.0) ^ (r->rod > 0.0)) {          /* fix orientation */
472                  for (i = 0; i < 3; i++)
473                          norm[i] += 2.0*newdot*r->rdir[i];
474                  newdot = -newdot;
# Line 543 | Line 557 | rayreject(             /* check if candidate hit is worse than cu
557                          return(1);      /* old has material, new does not */
558          } else if (mray == NULL) {
559                  return(0);              /* new has material, old does not */
560 <        } else if (istransp(mnew->otype)) {
561 <                if (!istransp(mray->otype))
560 >        } else if (istransp(mnew)) {
561 >                if (!istransp(mray))
562                          return(1);      /* new is transparent, old is not */
563 <        } else if (istransp(mray->otype)) {
563 >        } else if (istransp(mray)) {
564                  return(0);              /* old is transparent, new is not */
565          }
566          if (rod <= 0) {                 /* check which side we hit */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines