ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/m_bsdf.c
(Generate patch)

Comparing ray/src/rt/m_bsdf.c (file contents):
Revision 2.73 by greg, Wed Apr 17 16:46:00 2024 UTC vs.
Revision 2.77 by greg, Fri Jun 20 18:05:30 2025 UTC

# Line 238 | Line 238 | direct_specular_OK(SCOLOR scval, FVECT ldir, double om
238   {
239          int     nsamp = 1;
240          int     scnt = 0;
241 <        FVECT   vsrc, vjit;
241 >        FVECT   vsrc;
242          double  tomega, tomega2;
243          double  tsr, sd[2];
244          SCOLOR  csmp, cdiff;
# Line 306 | Line 306 | direct_specular_OK(SCOLOR scval, FVECT ldir, double om
306                  nsamp = 4.*specjitter*ndp->pr->rweight + .5;
307                  nsamp += !nsamp;
308          }
309 <                                        /* jitter to fuzz BSDF cells */
310 <        for (i = nsamp; i--; ) {
309 >        for (i = nsamp; i--; ) {        /* jitter to fuzz BSDF cells */
310 >                FVECT   vjit;
311                  bsdf_jitter(vjit, ndp, tsr);
312                                          /* compute BSDF */
313                  ec = SDevalBSDF(&sv, vjit, vsrc, ndp->sd);
314                  if (ec)
315                          goto baderror;
316 <                if (sv.cieY - diffY <= FTINY)
317 <                        continue;       /* no specular part */
316 >                if (sv.cieY - diffY <= FTINY) {
317 >                        ++scnt;         /* still counts as 0 contribution */
318 >                        continue;
319 >                }
320                                          /* check for variable resolution */
321                  ec = SDsizeBSDF(&tomega2, vjit, vsrc, SDqueryMin, ndp->sd);
322                  if (ec)
# Line 609 | Line 611 | sample_sdf(BSDFDAT *ndp, int sflags)
611                                  setscolor(unsc, b, b, b);
612                  }
613                  return(ntotal);
614 <        }
615 <        dimlist[ndims] = (int)(size_t)ndp->mp;  /* else sample specular */
616 <        ndims += 2;
614 >        }                                       /* else sample specular */
615 >        dimlist[ndims_inc()] = (int)(size_t)ndp->mp;
616 >        ndims_inc();
617          for (n = dfp->ncomp; n--; ) {           /* loop over components */
618                  dimlist[ndims-1] = n + 9438;
619                  ntotal += sample_sdcomp(ndp, &dfp->comp[n], sflags==SDsampSpT);
620          }
621 <        ndims -= 2;
621 >        dec_ndims(); dec_ndims();
622          return(ntotal);
623   }
624  
# Line 624 | Line 626 | sample_sdf(BSDFDAT *ndp, int sflags)
626   int
627   m_bsdf(OBJREC *m, RAY *r)
628   {
629 <        int     hasthick = (m->otype == MAT_BSDF);
630 <        int     hitfront;
629 >        const int       hasthick = (m->otype == MAT_BSDF);
630 >        const int       hitfront = (r->rod > 0);
631          SCOLOR  sctmp;
632          SDError ec;
633          FVECT   upvec, vtmp;
634          MFUNC   *mf;
635          BSDFDAT nd;
636 +                                                /* check backface visibility */
637 +        if (!hitfront & !backvis) {
638 +                raytrans(r);
639 +                return(1);
640 +        }
641                                                  /* check arguments */
642          if ((m->oargs.nsargs < hasthick+5) | (m->oargs.nfargs > 9) |
643                                  (m->oargs.nfargs % 3))
644                  objerror(m, USER, "bad # arguments");
638                                                /* record surface struck */
639        hitfront = (r->rod > 0);
645                                                  /* load cal file */
646          mf = hasthick   ? getfunc(m, 5, 0x1d, 1)
647                          : getfunc(m, 4, 0xe, 1) ;
# Line 646 | Line 651 | m_bsdf(OBJREC *m, RAY *r)
651                  nd.thick = evalue(mf->ep[0]);
652                  if ((-FTINY <= nd.thick) & (nd.thick <= FTINY))
653                          nd.thick = 0;
649        }
650                                                /* check backface visibility */
651        if (!hitfront & !backvis) {
652                raytrans(r);
653                return(1);
654          }
655                                                  /* check other rays to pass */
656          if (nd.thick != 0 && (r->crtype & SHADOW ||

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines