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.61 by greg, Thu Jul 9 17:32:31 2020 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 195 | Line 201 | compute_through(BSDFDAT *ndp)
201          }
202          if (vypeak*tomsurr < peak_over*bright(vsurr)*ns)
203                  return;                         /* peak not peaky enough */
204 <        if ((vypeak/ns - ndp->sd->tLamb.cieY*(1./PI))*tomsum <= .001)
204 >        if ((vypeak/ns - (ndp->vray[2] > 0 ? ndp->sd->tLambFront.cieY
205 >                        : ndp->sd->tLambBack.cieY)*(1./PI))*tomsum <= .001)
206                  return;                         /* < 0.1% transmission */
207          copycolor(ndp->cthru, vpeak);           /* already scaled by omega */
208          multcolor(ndp->cthru, ndp->pr->pcol);   /* modify by pattern */
# Line 207 | 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 255 | Line 263 | direct_specular_OK(COLOR cval, FVECT ldir, double omeg
263                          return(0);      /* all diffuse */
264                  sv = ndp->sd->rLambBack;
265                  break;
266 <        default:
266 >        case 1:
267                  if ((ndp->sd->tf == NULL) & (ndp->sd->tb == NULL))
268                          return(0);      /* all diffuse */
269 <                sv = ndp->sd->tLamb;
269 >                sv = ndp->sd->tLambFront;
270                  break;
271 +        case 2:
272 +                if ((ndp->sd->tf == NULL) & (ndp->sd->tb == NULL))
273 +                        return(0);      /* all diffuse */
274 +                sv = ndp->sd->tLambBack;
275 +                break;
276          }
277          if (sv.cieY > FTINY) {
278                  diffY = sv.cieY *= 1./PI;
# Line 677 | 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 686 | 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 694 | 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 */
699 <        cvt_sdcolor(nd.tdiff, &nd.sd->tLamb);
700 <        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