| 19 |
|
#include "bsdfrep.h" |
| 20 |
|
/* global argv[0] */ |
| 21 |
|
char *progname; |
| 22 |
+ |
/* reciprocity averaging option */ |
| 23 |
+ |
static const char *recip = " -a"; |
| 24 |
|
/* percentage to cull (<0 to turn off) */ |
| 25 |
|
static double pctcull = 90.; |
| 26 |
|
/* sampling order */ |
| 40 |
|
static char *wrapBSDF[MAXCARG] = {"wrapBSDF", "-U"}; |
| 41 |
|
static int wbsdfac = 2; |
| 42 |
|
|
| 43 |
< |
/* Add argument to wrapBSDF, allocating space if isstatic */ |
| 43 |
> |
/* Add argument to wrapBSDF, allocating space if !isstatic */ |
| 44 |
|
static void |
| 45 |
|
add_wbsdf(const char *arg, int isstatic) |
| 46 |
|
{ |
| 137 |
|
float bsdf, uv[2]; |
| 138 |
|
|
| 139 |
|
if (pctcull >= 0) { |
| 140 |
< |
sprintf(cmd, "rttree_reduce -a -h -ff -r 3 -t %f -g %d > %s", |
| 141 |
< |
pctcull, samp_order, create_component_file(0)); |
| 140 |
> |
sprintf(cmd, "rttree_reduce%s -h -ff -r 3 -t %f -g %d > %s", |
| 141 |
> |
recip, pctcull, samp_order, create_component_file(0)); |
| 142 |
|
ofp = popen(cmd, "w"); |
| 143 |
|
if (ofp == NULL) { |
| 144 |
|
fprintf(stderr, "%s: cannot create pipe to rttree_reduce\n", |
| 151 |
|
#endif |
| 152 |
|
if (rbf_colorimetry == RBCtristimulus) { |
| 153 |
|
double uvcull = 100. - (100.-pctcull)*.25; |
| 154 |
< |
sprintf(cmd, "rttree_reduce -a -h -ff -r 3 -t %f -g %d > %s", |
| 155 |
< |
uvcull, samp_order, create_component_file(1)); |
| 154 |
> |
sprintf(cmd, "rttree_reduce%s -h -ff -r 3 -t %f -g %d > %s", |
| 155 |
> |
recip, uvcull, samp_order, create_component_file(1)); |
| 156 |
|
uvfp[0] = popen(cmd, "w"); |
| 157 |
< |
sprintf(cmd, "rttree_reduce -a -h -ff -r 3 -t %f -g %d > %s", |
| 158 |
< |
uvcull, samp_order, create_component_file(2)); |
| 157 |
> |
sprintf(cmd, "rttree_reduce%s -h -ff -r 3 -t %f -g %d > %s", |
| 158 |
> |
recip, uvcull, samp_order, create_component_file(2)); |
| 159 |
|
uvfp[1] = popen(cmd, "w"); |
| 160 |
|
if ((uvfp[0] == NULL) | (uvfp[1] == NULL)) { |
| 161 |
|
fprintf(stderr, "%s: cannot open pipes to uv output\n", |
| 208 |
|
eval_rbfcol(&sdv, rbf, iovec+3); |
| 209 |
|
bsdf = sdv.cieY; |
| 210 |
|
if (rbf_colorimetry == RBCtristimulus) { |
| 209 |
– |
c_ccvt(&sdv.spec, C_CSXY); |
| 211 |
|
uv[0] = uv[1] = 1. / |
| 212 |
|
(-2.*sdv.spec.cx + 12.*sdv.spec.cy + 3.); |
| 213 |
|
uv[0] *= 4.*sdv.spec.cx; |
| 323 |
|
|
| 324 |
|
if (pctcull >= 0) { |
| 325 |
|
const char *avgopt = (input_orient>0 ^ output_orient>0) |
| 326 |
< |
? "" : " -a"; |
| 326 |
> |
? "" : recip; |
| 327 |
|
sprintf(cmd, "rttree_reduce%s -h -ff -r 4 -t %f -g %d > %s", |
| 328 |
|
avgopt, pctcull, samp_order, |
| 329 |
|
create_component_file(0)); |
| 399 |
|
eval_rbfcol(&sdv, rbf, iovec+3); |
| 400 |
|
bsdf = sdv.cieY; |
| 401 |
|
if (rbf_colorimetry == RBCtristimulus) { |
| 401 |
– |
c_ccvt(&sdv.spec, C_CSXY); |
| 402 |
|
uv[0] = uv[1] = 1. / |
| 403 |
|
(-2.*sdv.spec.cx + 12.*sdv.spec.cy + 3.); |
| 404 |
|
uv[0] *= 4.*sdv.spec.cx; |
| 565 |
|
esupport &= ~(E_INCHAN|E_OUTCHAN); |
| 566 |
|
scompile("PI:3.14159265358979323846", NULL, 0); |
| 567 |
|
biggerlib(); |
| 568 |
< |
for (i = 1; i < argc-1 && (argv[i][0] == '-') | (argv[i][0] == '+'); i++) |
| 568 |
> |
for (i = 1; i < argc && (argv[i][0] == '-') | (argv[i][0] == '+'); i++) |
| 569 |
|
switch (argv[i][1]) { /* get options */ |
| 570 |
|
case 'e': |
| 571 |
|
scompile(argv[++i], NULL, 0); |
| 580 |
|
} else |
| 581 |
|
dofwd = (argv[i][0] == '+'); |
| 582 |
|
break; |
| 583 |
+ |
case 'a': |
| 584 |
+ |
recip = (argv[i][0] == '+') ? " -a" : ""; |
| 585 |
+ |
break; |
| 586 |
|
case 'b': |
| 587 |
|
dobwd = (argv[i][0] == '+'); |
| 588 |
|
break; |
| 698 |
|
return(wrap_up()); |
| 699 |
|
userr: |
| 700 |
|
fprintf(stderr, |
| 701 |
< |
"Usage: %s [-g Nlog2][-t pctcull][-l maxlobes] [bsdf.sir ..] > bsdf.xml\n", |
| 701 |
> |
"Usage: %s [{+|-}a][-g Nlog2][-t pctcull][-l maxlobes] [bsdf.sir ..] > bsdf.xml\n", |
| 702 |
|
progname); |
| 703 |
|
fprintf(stderr, |
| 704 |
< |
" or: %s -t{3|4} [-g Nlog2][-t pctcull][{+|-}for[ward]][{+|-}b[ackward]][-e expr][-f file] bsdf_func > bsdf.xml\n", |
| 704 |
> |
" or: %s -t{3|4} [{+|-}a][-g Nlog2][-t pctcull][{+|-}for[ward]][{+|-}b[ackward]][-e expr][-f file] bsdf_func > bsdf.xml\n", |
| 705 |
|
progname); |
| 706 |
|
return(1); |
| 707 |
|
} |