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.62 by greg, Sat Mar 27 17:50:18 2021 UTC vs.
Revision 2.64 by greg, Wed Aug 25 16:12:21 2021 UTC

# Line 130 | Line 130 | compute_through(BSDFDAT *ndp)
130                                          {1.8, -1.8}, {-2.4, 0}, {0, 2.4},
131                                          {0, -2.4}, {2.4, 0},
132                                  };
133 + #define neighbors(i,j)  \
134 +        ((dir2check[i][0]-dir2check[j][0])*(dir2check[i][0]-dir2check[j][0]) + \
135 +        (dir2check[i][1]-dir2check[j][1])*(dir2check[i][1]-dir2check[j][1]) <= 0.73)
136          const double    peak_over = 1.5;
137          PEAKSAMP        psamp[NDIR2CHECK];
138          SDSpectralDF    *dfp;
# Line 138 | Line 141 | compute_through(BSDFDAT *ndp)
141          double          tomsum, tomsurr;
142          COLOR           vpeak, vsurr;
143          double          vypeak;
144 <        int             i, ns;
144 >        int             i, j, ns;
145          SDError         ec;
146  
147          if (ndp->pr->rod > 0)
# Line 171 | Line 174 | compute_through(BSDFDAT *ndp)
174          vypeak = tomsum = tomsurr = 0;          /* combine top unique values */
175          ns = 0;
176          for (i = 0; i < NDIR2CHECK; i++) {
177 <                if (i && psamp[i].vy == psamp[i-1].vy)
178 <                        continue;               /* assume duplicate sample */
177 >                for (j = i; j--; )              /* check for duplicate sample */
178 >                        if (psamp[j].vy == psamp[i].vy && neighbors(i,j))
179 >                                break;
180 >                if (j >= 0)
181 >                        continue;               /* skip duplicate */
182  
183                  ec = SDsizeBSDF(&tomega, psamp[i].tdir, ndp->vray,
184                                                  SDqueryMin, ndp->sd);
# Line 208 | Line 214 | compute_through(BSDFDAT *ndp)
214          return;
215   baderror:
216          objerror(ndp->mp, USER, transSDError(ec));
217 + #undef neighbors
218   #undef NDIR2CHECK
219   }
220  
# Line 683 | Line 690 | m_bsdf(OBJREC *m, RAY *r)
690                  SDfreeCache(nd.sd);
691                  return(1);
692          }
693 <                                                /* diffuse reflectance */
693 >                                                /* diffuse components */
694          if (hitfront) {
695                  cvt_sdcolor(nd.rdiff, &nd.sd->rLambFront);
696                  if (m->oargs.nfargs >= 3) {
# Line 692 | Line 699 | m_bsdf(OBJREC *m, RAY *r)
699                                          m->oargs.farg[2]);
700                          addcolor(nd.rdiff, ctmp);
701                  }
702 +                cvt_sdcolor(nd.tdiff, &nd.sd->tLambFront);
703          } else {
704                  cvt_sdcolor(nd.rdiff, &nd.sd->rLambBack);
705                  if (m->oargs.nfargs >= 6) {
# Line 700 | Line 708 | m_bsdf(OBJREC *m, RAY *r)
708                                          m->oargs.farg[5]);
709                          addcolor(nd.rdiff, ctmp);
710                  }
711 +                cvt_sdcolor(nd.tdiff, &nd.sd->tLambBack);
712          }
713 <                                                /* diffuse transmittance */
705 <        cvt_sdcolor(nd.tdiff, hitfront ? &nd.sd->tLambFront : &nd.sd->tLambBack);
706 <        if (m->oargs.nfargs >= 9) {
713 >        if (m->oargs.nfargs >= 9) {             /* add diffuse transmittance? */
714                  setcolor(ctmp, m->oargs.farg[6],
715                                  m->oargs.farg[7],
716                                  m->oargs.farg[8]);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines