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.10 by greg, Mon Sep 11 18:43:36 2023 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 >        double  Lamb = 0;
84 >
85 >        fputs(nm, stdout);
86 >        if (lamb->spec.flags) {
87 >                printf("\t%4.1f %4.1f %4.1f\t\t",
88                          100.*lamb->cieY*lamb->spec.cx/lamb->spec.cy,
89                          100.*lamb->cieY,
90                          100.*lamb->cieY*(1.f - lamb->spec.cx - lamb->spec.cy)/lamb->spec.cy);
91 +                Lamb = lamb->cieY;
92 +        } else
93 +                fputs("\t 0    0    0\t\t", stdout);
94          if (df)
95 <                printf("%5.1f%%\t\t%.2f deg\n", 100.*df->maxHemi,
95 >                printf("%5.1f%%\t\t%.2f deg\n", 100.*(Lamb+df->maxHemi),
96                                  sqrt(df->minProjSA/M_PI)*(360./M_PI));
97          else
98 <                puts("0%\t\t180");
98 >                printf("%5.1f%%\t\t180 deg\n", Lamb);
99   }
100  
101   /* Add a value to stats */
# Line 177 | Line 184 | checkReciprocity(const char *nm, const int side1, cons
184          if (fl & F_MATRIX) {                    /* special case for matrix BSDF */
185                  const SDMat     *m = (const SDMat *)df->comp[0].dist;
186                  int             i = m->ninc;
187 +                double          diffuseY;
188                  FVECT           vin, vout;
189                  double          fwdY;
190                  SDValue         rev;
191 +                if (side1 == side2)
192 +                        diffuseY = (side1 > 0) ? bsdf->rLambFront.cieY : bsdf->rLambBack.cieY;
193 +                else
194 +                        diffuseY = (side1 > 0) ? bsdf->tLambFront.cieY : bsdf->tLambBack.cieY;
195 +                diffuseY /= M_PI;
196                  while (i--) {
197                      int o = m->nout;
198                      if (!mBSDF_incvec(vin, m, i+.5))
# Line 187 | Line 200 | checkReciprocity(const char *nm, const int side1, cons
200                      while (o--) {
201                          if (!mBSDF_outvec(vout, m, o+.5))
202                                  continue;
203 <                        fwdY = mBSDF_value(m, o, i);
203 >                        fwdY = mBSDF_value(m, o, i) + diffuseY;
204                          if (fwdY <= 1e-4)
205                                  continue;
206                          if (SDreportError( SDevalBSDF(&rev, vout, vin, bsdf), stderr))
# Line 196 | Line 209 | checkReciprocity(const char *nm, const int side1, cons
209                                  addStat(&myStats, rdiff(fwdY, rev.cieY));
210                      }
211                  }
212 <        } if (fl & F_ISOTROPIC) {               /* isotropic case */
212 >        } else if (fl & F_ISOTROPIC) {          /* isotropic case */
213                  const double    stepSize = sqrt(df->minProjSA/M_PI);
214                  FVECT           vin;
215                  vin[1] = 0;
# Line 216 | Line 229 | checkReciprocity(const char *nm, const int side1, cons
229                  return;
230          }
231   nothing2do:
232 <        printf("%s\t0\t0\t0\n", nm);
232 >        printf("%s\t  0\t  0\t  0\n", nm);
233   }
234  
235   /* Report on the given BSDF XML file */
# Line 230 | Line 243 | checkXML(char *fname)
243          puts("=====================================================");
244          printf("File: '%s'\n", fname);
245          SDclearBSDF(&myBSDF, fname);
246 <        pth = getpath(fname, getrlibpath(), R_OK);
246 >        pth = getpath(fname, getrlibpath(), 0);
247          if (!pth) {
248                  fprintf(stderr, "Cannot find file '%s'\n", fname);
249                  return 0;
# Line 244 | Line 257 | checkXML(char *fname)
257          printf("Type: %s\n", getBSDFtype(&myBSDF, &flags));
258          printf("Color: %d\n", (flags & F_IN_COLOR) != 0);
259          printf("Has Geometry: %d\n", (myBSDF.mgf != NULL));
260 <        puts("Component\tLambertian XYZ %\tMax. Dir\tMin. Angle");
261 <        detailComponent("Internal Refl", &myBSDF.rLambFront, myBSDF.rf);
262 <        detailComponent("External Refl", &myBSDF.rLambBack, myBSDF.rb);
260 >        puts("Component\tLambertian XYZ (%)\tMax. Tot. Dir\tMin. Angle");
261 >        detailComponent("Interior Refl", &myBSDF.rLambFront, myBSDF.rf);
262 >        detailComponent("Exterior Refl", &myBSDF.rLambBack, myBSDF.rb);
263          detailComponent("Int->Ext Trans", &myBSDF.tLambFront, myBSDF.tf);
264          detailComponent("Ext->Int Trans", &myBSDF.tLambBack, myBSDF.tb);
265          puts("Component\tReciprocity Error (min avg max %)");
266 <        checkReciprocity("Front Refl", 1, 1, &myBSDF, flags);
267 <        checkReciprocity("Back Refl", -1, -1, &myBSDF, flags);
266 >        checkReciprocity("Interior Refl", 1, 1, &myBSDF, flags);
267 >        checkReciprocity("Exterior Refl", -1, -1, &myBSDF, flags);
268          checkReciprocity("Transmission", -1, 1, &myBSDF, flags);
269          SDfreeBSDF(&myBSDF);
270          return 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines