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

Comparing ray/src/cv/checkBSDF.c (file contents):
Revision 2.2 by greg, Wed Dec 15 02:13:27 2021 UTC vs.
Revision 2.7 by greg, Fri Jan 28 02:25:28 2022 UTC

# Line 29 | Line 29 | typedef struct {
29   const SimpleStats       SSinit = {FHUGE, -FHUGE, .0, 0};
30  
31                                  /* relative difference formula */
32 < #define rdiff(a,b)      ((a)>(b) ? ((a)-(b))/(a) : ((b)-(a))/(b))
32 > #define rdiff(a,b)      ((a)>(b) ? ((a)-(b))/((a)+FTINY) : ((b)-(a))/((b)+FTINY))
33  
34   /* Figure out BSDF type (and optionally determine if in color) */
35   const char *
# Line 80 | Line 80 | getBSDFtype(const SDData *bsdf, int *flags)
80   void
81   detailComponent(const char *nm, const SDValue *lamb, const SDSpectralDF *df)
82   {
83 <        printf("%s\t%4.1f %4.1f %4.1f\t\t", nm,
83 >        fputs(nm, stdout);
84 >        if (lamb->spec.flags)
85 >                printf("\t%4.1f %4.1f %4.1f\t\t",
86                          100.*lamb->cieY*lamb->spec.cx/lamb->spec.cy,
87                          100.*lamb->cieY,
88                          100.*lamb->cieY*(1.f - lamb->spec.cx - lamb->spec.cy)/lamb->spec.cy);
89 +        else
90 +                fputs("\t 0    0    0\t\t", stdout);
91          if (df)
92                  printf("%5.1f%%\t\t%.2f deg\n", 100.*df->maxHemi,
93                                  sqrt(df->minProjSA/M_PI)*(360./M_PI));
94          else
95 <                puts("0%\t\t180");
95 >                puts("  0%\t\t180 deg");
96   }
97  
98   /* Add a value to stats */
# Line 177 | Line 181 | checkReciprocity(const char *nm, const int side1, cons
181          if (fl & F_MATRIX) {                    /* special case for matrix BSDF */
182                  const SDMat     *m = (const SDMat *)df->comp[0].dist;
183                  int             i = m->ninc;
184 +                double          diffuseY;
185                  FVECT           vin, vout;
186                  double          fwdY;
187                  SDValue         rev;
188 +                if (side1 == side2)
189 +                        diffuseY = (side1 > 0) ? bsdf->rLambFront.cieY : bsdf->rLambBack.cieY;
190 +                else
191 +                        diffuseY = (side1 > 0) ? bsdf->tLambFront.cieY : bsdf->tLambBack.cieY;
192 +                diffuseY /= M_PI;
193                  while (i--) {
194                      int o = m->nout;
195                      if (!mBSDF_incvec(vin, m, i+.5))
# Line 187 | Line 197 | checkReciprocity(const char *nm, const int side1, cons
197                      while (o--) {
198                          if (!mBSDF_outvec(vout, m, o+.5))
199                                  continue;
200 <                        fwdY = mBSDF_value(m, o, i);
200 >                        fwdY = mBSDF_value(m, o, i) + diffuseY;
201                          if (fwdY <= 1e-4)
202                                  continue;
203                          if (SDreportError( SDevalBSDF(&rev, vout, vin, bsdf), stderr))
# Line 196 | Line 206 | checkReciprocity(const char *nm, const int side1, cons
206                                  addStat(&myStats, rdiff(fwdY, rev.cieY));
207                      }
208                  }
209 <        } if (fl & F_ISOTROPIC) {               /* isotropic case */
209 >        } else if (fl & F_ISOTROPIC) {          /* isotropic case */
210                  const double    stepSize = sqrt(df->minProjSA/M_PI);
211                  FVECT           vin;
212                  vin[1] = 0;
# Line 216 | Line 226 | checkReciprocity(const char *nm, const int side1, cons
226                  return;
227          }
228   nothing2do:
229 <        printf("%s\t0\t0\t0\n", nm);
229 >        printf("%s\t  0\t  0\t  0\n", nm);
230   }
231  
232   /* Report on the given BSDF XML file */
# Line 230 | Line 240 | checkXML(char *fname)
240          puts("=====================================================");
241          printf("File: '%s'\n", fname);
242          SDclearBSDF(&myBSDF, fname);
243 <        pth = getpath(fname, getrlibpath(), R_OK);
243 >        pth = getpath(fname, getrlibpath(), 0);
244          if (!pth) {
245                  fprintf(stderr, "Cannot find file '%s'\n", fname);
246                  return 0;
# Line 245 | Line 255 | checkXML(char *fname)
255          printf("Color: %d\n", (flags & F_IN_COLOR) != 0);
256          printf("Has Geometry: %d\n", (myBSDF.mgf != NULL));
257          puts("Component\tLambertian XYZ %\tMax. Dir\tMin. Angle");
258 <        detailComponent("Internal Refl", &myBSDF.rLambFront, myBSDF.rf);
259 <        detailComponent("External Refl", &myBSDF.rLambBack, myBSDF.rb);
258 >        detailComponent("Interior Refl", &myBSDF.rLambFront, myBSDF.rf);
259 >        detailComponent("Exterior Refl", &myBSDF.rLambBack, myBSDF.rb);
260          detailComponent("Int->Ext Trans", &myBSDF.tLambFront, myBSDF.tf);
261          detailComponent("Ext->Int Trans", &myBSDF.tLambBack, myBSDF.tb);
262          puts("Component\tReciprocity Error (min avg max %)");
263 <        checkReciprocity("Front Refl", 1, 1, &myBSDF, flags);
264 <        checkReciprocity("Back Refl", -1, -1, &myBSDF, flags);
263 >        checkReciprocity("Interior Refl", 1, 1, &myBSDF, flags);
264 >        checkReciprocity("Exterior Refl", -1, -1, &myBSDF, flags);
265          checkReciprocity("Transmission", -1, 1, &myBSDF, flags);
266          SDfreeBSDF(&myBSDF);
267          return 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines