| 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 * |
| 177 |
|
if (fl & F_MATRIX) { /* special case for matrix BSDF */ |
| 178 |
|
const SDMat *m = (const SDMat *)df->comp[0].dist; |
| 179 |
|
int i = m->ninc; |
| 180 |
+ |
double diffuseY; |
| 181 |
|
FVECT vin, vout; |
| 182 |
|
double fwdY; |
| 183 |
|
SDValue rev; |
| 184 |
+ |
if (side1 == side2) |
| 185 |
+ |
diffuseY = (side1 > 0) ? bsdf->rLambFront.cieY : bsdf->rLambBack.cieY; |
| 186 |
+ |
else |
| 187 |
+ |
diffuseY = (side1 > 0) ? bsdf->tLambFront.cieY : bsdf->tLambBack.cieY; |
| 188 |
+ |
diffuseY /= M_PI; |
| 189 |
|
while (i--) { |
| 190 |
|
int o = m->nout; |
| 191 |
|
if (!mBSDF_incvec(vin, m, i+.5)) |
| 193 |
|
while (o--) { |
| 194 |
|
if (!mBSDF_outvec(vout, m, o+.5)) |
| 195 |
|
continue; |
| 196 |
< |
fwdY = mBSDF_value(m, o, i); |
| 196 |
> |
fwdY = mBSDF_value(m, o, i) + diffuseY; |
| 197 |
|
if (fwdY <= 1e-4) |
| 198 |
|
continue; |
| 199 |
|
if (SDreportError( SDevalBSDF(&rev, vout, vin, bsdf), stderr)) |
| 202 |
|
addStat(&myStats, rdiff(fwdY, rev.cieY)); |
| 203 |
|
} |
| 204 |
|
} |
| 205 |
< |
} if (fl & F_ISOTROPIC) { /* isotropic case */ |
| 205 |
> |
} else if (fl & F_ISOTROPIC) { /* isotropic case */ |
| 206 |
|
const double stepSize = sqrt(df->minProjSA/M_PI); |
| 207 |
|
FVECT vin; |
| 208 |
|
vin[1] = 0; |
| 236 |
|
puts("====================================================="); |
| 237 |
|
printf("File: '%s'\n", fname); |
| 238 |
|
SDclearBSDF(&myBSDF, fname); |
| 239 |
< |
pth = getpath(fname, getrlibpath(), R_OK); |
| 239 |
> |
pth = getpath(fname, getrlibpath(), 0); |
| 240 |
|
if (!pth) { |
| 241 |
|
fprintf(stderr, "Cannot find file '%s'\n", fname); |
| 242 |
|
return 0; |
| 251 |
|
printf("Color: %d\n", (flags & F_IN_COLOR) != 0); |
| 252 |
|
printf("Has Geometry: %d\n", (myBSDF.mgf != NULL)); |
| 253 |
|
puts("Component\tLambertian XYZ %\tMax. Dir\tMin. Angle"); |
| 254 |
< |
detailComponent("Internal Refl", &myBSDF.rLambFront, myBSDF.rf); |
| 255 |
< |
detailComponent("External Refl", &myBSDF.rLambBack, myBSDF.rb); |
| 254 |
> |
detailComponent("Interior Refl", &myBSDF.rLambFront, myBSDF.rf); |
| 255 |
> |
detailComponent("Exterior Refl", &myBSDF.rLambBack, myBSDF.rb); |
| 256 |
|
detailComponent("Int->Ext Trans", &myBSDF.tLambFront, myBSDF.tf); |
| 257 |
|
detailComponent("Ext->Int Trans", &myBSDF.tLambBack, myBSDF.tb); |
| 258 |
|
puts("Component\tReciprocity Error (min avg max %)"); |
| 259 |
< |
checkReciprocity("Front Refl", 1, 1, &myBSDF, flags); |
| 260 |
< |
checkReciprocity("Back Refl", -1, -1, &myBSDF, flags); |
| 259 |
> |
checkReciprocity("Interior Refl", 1, 1, &myBSDF, flags); |
| 260 |
> |
checkReciprocity("Exterior Refl", -1, -1, &myBSDF, flags); |
| 261 |
|
checkReciprocity("Transmission", -1, 1, &myBSDF, flags); |
| 262 |
|
SDfreeBSDF(&myBSDF); |
| 263 |
|
return 1; |