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 */ |
29 |
|
const double ssamp_thresh = 0.35; |
30 |
|
/* number of super-samples */ |
31 |
|
#ifndef NSSAMP |
32 |
< |
#define NSSAMP 100 |
32 |
> |
#define NSSAMP 64 |
33 |
|
#endif |
34 |
|
/* limit on number of RBF lobes */ |
35 |
|
static int lobe_lim = 15000; |
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; |
251 |
|
#endif |
252 |
|
} |
253 |
|
if (pctcull >= 0) |
254 |
< |
fwrite(&bsdf, sizeof(bsdf), 1, ofp); |
254 |
> |
putbinary(&bsdf, sizeof(bsdf), 1, ofp); |
255 |
|
else |
256 |
|
fprintf(ofp, "\t%.3e\n", bsdf); |
257 |
|
|
258 |
|
if (rbf_colorimetry == RBCtristimulus) { |
259 |
|
if (pctcull >= 0) { |
260 |
< |
fwrite(&uv[0], sizeof(*uv), 1, uvfp[0]); |
261 |
< |
fwrite(&uv[1], sizeof(*uv), 1, uvfp[1]); |
260 |
> |
putbinary(&uv[0], sizeof(*uv), 1, uvfp[0]); |
261 |
> |
putbinary(&uv[1], sizeof(*uv), 1, uvfp[1]); |
262 |
|
} else { |
263 |
|
fprintf(uvfp[0], "\t%.3e\n", uv[0]); |
264 |
|
fprintf(uvfp[1], "\t%.3e\n", uv[1]); |
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; |
443 |
|
#endif |
444 |
|
} |
445 |
|
if (pctcull >= 0) |
446 |
< |
fwrite(&bsdf, sizeof(bsdf), 1, ofp); |
446 |
> |
putbinary(&bsdf, sizeof(bsdf), 1, ofp); |
447 |
|
else |
448 |
|
fprintf(ofp, "\t%.3e\n", bsdf); |
449 |
|
|
450 |
|
if (rbf_colorimetry == RBCtristimulus) { |
451 |
|
if (pctcull >= 0) { |
452 |
< |
fwrite(&uv[0], sizeof(*uv), 1, uvfp[0]); |
453 |
< |
fwrite(&uv[1], sizeof(*uv), 1, uvfp[1]); |
452 |
> |
putbinary(&uv[0], sizeof(*uv), 1, uvfp[0]); |
453 |
> |
putbinary(&uv[1], sizeof(*uv), 1, uvfp[1]); |
454 |
|
} else { |
455 |
|
fprintf(uvfp[0], "\t%.3e\n", uv[0]); |
456 |
|
fprintf(uvfp[1], "\t%.3e\n", uv[1]); |
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 |
|
} |