--- ray/src/cv/pabopto2bsdf.c 2013/11/08 03:43:01 2.9 +++ ray/src/cv/pabopto2bsdf.c 2014/03/08 01:05:00 2.15 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: pabopto2bsdf.c,v 2.9 2013/11/08 03:43:01 greg Exp $"; +static const char RCSid[] = "$Id: pabopto2bsdf.c,v 2.15 2014/03/08 01:05:00 greg Exp $"; #endif /* * Load measured BSDF data in PAB-Opto format. @@ -14,6 +14,7 @@ static const char RCSid[] = "$Id: pabopto2bsdf.c,v 2.9 #include #include "platform.h" #include "bsdfrep.h" +#include "resolu.h" /* global argv[0] */ char *progname; @@ -70,6 +71,8 @@ init_pabopto_inp(const int i, const char *fname) fclose(fp); return(0); } + if (sscanf(buf, "sample_name \"%[^\"]\"", bsdf_name) == 1) + continue; if (sscanf(buf, "format: theta phi %s", typ) == 1) { if (!strcasecmp(typ, "DSF")) { inpfile[i].isDSF = 1; @@ -217,9 +220,9 @@ main(int argc, char *argv[]) #ifdef DEBUG fprintf(stderr, "Minimum BSDF = %.4f\n", bsdf_min); #endif - /* produce spheres at meas. */ + min_log = log(bsdf_min*.5 + 1e-5); +#if 1 /* produce spheres at meas. */ puts("void plastic yellow\n0\n0\n5 .6 .4 .01 .04 .08\n"); - min_log = log(bsdf_min*.5); n = 0; for (i = 0; i < GRIDRES; i++) for (j = 0; j < GRIDRES; j++) @@ -229,14 +232,28 @@ main(int argc, char *argv[]) (dsf_grid[i][j].nval*output_orient*dir[2]); if (bsdf <= bsdf_min*.6) continue; - bsdf = log(bsdf) - min_log; + bsdf = log(bsdf + 1e-5) - min_log; ovec_from_pos(dir, i, j); printf("yellow sphere s%04d\n0\n0\n", ++n); printf("4 %.6g %.6g %.6g %.6g\n\n", dir[0]*bsdf, dir[1]*bsdf, dir[2]*bsdf, .007*bsdf); } - /* output continuous surface */ +#endif +#if 1 /* spheres at RBF peaks */ + puts("void plastic red\n0\n0\n5 .8 .01 .01 .04 .08\n"); + for (n = 0; n < dsf_list->nrbf; n++) { + RBFVAL *rbf = &dsf_list->rbfa[n]; + ovec_from_pos(dir, rbf->gx, rbf->gy); + bsdf = eval_rbfrep(dsf_list, dir) / (output_orient*dir[2]); + bsdf = log(bsdf + 1e-5) - min_log; + printf("red sphere p%04d\n0\n0\n", ++n); + printf("4 %.6g %.6g %.6g %.6g\n\n", + dir[0]*bsdf, dir[1]*bsdf, dir[2]*bsdf, + .011*bsdf); + } +#endif +#if 1 /* output continuous surface */ puts("void trans tgreen\n0\n0\n7 .7 1 .7 .04 .04 .9 1\n"); fflush(stdout); sprintf(buf, "gensurf tgreen bsdf - - - %d %d", GRIDRES-1, GRIDRES-1); @@ -249,10 +266,13 @@ main(int argc, char *argv[]) for (j = 0; j < GRIDRES; j++) { ovec_from_pos(dir, i, j); bsdf = eval_rbfrep(dsf_list, dir) / (output_orient*dir[2]); - bsdf = log(bsdf) - min_log; + bsdf = log(bsdf + 1e-5) - min_log; fprintf(pfp, "%.8e %.8e %.8e\n", dir[0]*bsdf, dir[1]*bsdf, dir[2]*bsdf); } - return(pclose(pfp)==0 ? 0 : 1); + if (pclose(pfp) != 0) + return(1); +#endif + return(0); } #endif