27 |
|
const double ssamp_thresh = 0.35; |
28 |
|
/* number of super-samples */ |
29 |
|
#ifndef NSSAMP |
30 |
< |
#define NSSAMP 100 |
30 |
> |
#define NSSAMP 64 |
31 |
|
#endif |
32 |
|
/* limit on number of RBF lobes */ |
33 |
|
static int lobe_lim = 15000; |
38 |
|
static char *wrapBSDF[MAXCARG] = {"wrapBSDF", "-U"}; |
39 |
|
static int wbsdfac = 2; |
40 |
|
|
41 |
< |
/* Add argument to wrapBSDF, allocating space if isstatic */ |
41 |
> |
/* Add argument to wrapBSDF, allocating space if !isstatic */ |
42 |
|
static void |
43 |
|
add_wbsdf(const char *arg, int isstatic) |
44 |
|
{ |
185 |
|
fputs("{\n", uvfp[1]); |
186 |
|
} |
187 |
|
} |
188 |
< |
/* need to assign Dx, Dy, Dz? */ |
189 |
< |
if (funame != NULL) |
188 |
> |
if (funame != NULL) /* need to assign Dx, Dy, Dz? */ |
189 |
|
assignD = (fundefined(funame) < 6); |
190 |
|
/* run through directions */ |
191 |
|
for (ix = 0; ix < sqres/2; ix++) { |
206 |
|
eval_rbfcol(&sdv, rbf, iovec+3); |
207 |
|
bsdf = sdv.cieY; |
208 |
|
if (rbf_colorimetry == RBCtristimulus) { |
210 |
– |
c_ccvt(&sdv.spec, C_CSXY); |
209 |
|
uv[0] = uv[1] = 1. / |
210 |
|
(-2.*sdv.spec.cx + 12.*sdv.spec.cy + 3.); |
211 |
|
uv[0] *= 4.*sdv.spec.cx; |
249 |
|
#endif |
250 |
|
} |
251 |
|
if (pctcull >= 0) |
252 |
< |
fwrite(&bsdf, sizeof(bsdf), 1, ofp); |
252 |
> |
putbinary(&bsdf, sizeof(bsdf), 1, ofp); |
253 |
|
else |
254 |
|
fprintf(ofp, "\t%.3e\n", bsdf); |
255 |
|
|
256 |
|
if (rbf_colorimetry == RBCtristimulus) { |
257 |
|
if (pctcull >= 0) { |
258 |
< |
fwrite(&uv[0], sizeof(*uv), 1, uvfp[0]); |
259 |
< |
fwrite(&uv[1], sizeof(*uv), 1, uvfp[1]); |
258 |
> |
putbinary(&uv[0], sizeof(*uv), 1, uvfp[0]); |
259 |
> |
putbinary(&uv[1], sizeof(*uv), 1, uvfp[1]); |
260 |
|
} else { |
261 |
|
fprintf(uvfp[0], "\t%.3e\n", uv[0]); |
262 |
|
fprintf(uvfp[1], "\t%.3e\n", uv[1]); |
269 |
|
free(rbf); |
270 |
|
prog_show((ix+1.)*(2./sqres)); |
271 |
|
} |
272 |
+ |
prog_done(); |
273 |
|
if (pctcull >= 0) { /* finish output */ |
274 |
|
if (pclose(ofp)) { |
275 |
|
fprintf(stderr, "%s: error running rttree_reduce on Y\n", |
305 |
|
} |
306 |
|
} |
307 |
|
} |
309 |
– |
prog_done(); |
308 |
|
} |
309 |
|
|
310 |
|
/* Interpolate and output anisotropic BSDF data */ |
320 |
|
float bsdf, uv[2]; |
321 |
|
|
322 |
|
if (pctcull >= 0) { |
323 |
+ |
const char *avgopt = (input_orient>0 ^ output_orient>0) |
324 |
+ |
? "" : " -a"; |
325 |
|
sprintf(cmd, "rttree_reduce%s -h -ff -r 4 -t %f -g %d > %s", |
326 |
< |
(input_orient>0 ^ output_orient>0) ? "" : " -a", |
327 |
< |
pctcull, samp_order, create_component_file(0)); |
326 |
> |
avgopt, pctcull, samp_order, |
327 |
> |
create_component_file(0)); |
328 |
|
ofp = popen(cmd, "w"); |
329 |
|
if (ofp == NULL) { |
330 |
|
fprintf(stderr, "%s: cannot create pipe to rttree_reduce\n", |
338 |
|
if (rbf_colorimetry == RBCtristimulus) { |
339 |
|
double uvcull = 100. - (100.-pctcull)*.25; |
340 |
|
sprintf(cmd, "rttree_reduce%s -h -ff -r 4 -t %f -g %d > %s", |
341 |
< |
(input_orient>0 ^ output_orient>0) ? "" : " -a", |
342 |
< |
uvcull, samp_order, create_component_file(1)); |
341 |
> |
avgopt, uvcull, samp_order, |
342 |
> |
create_component_file(1)); |
343 |
|
uvfp[0] = popen(cmd, "w"); |
344 |
|
sprintf(cmd, "rttree_reduce%s -h -ff -r 4 -t %f -g %d > %s", |
345 |
< |
(input_orient>0 ^ output_orient>0) ? "" : " -a", |
346 |
< |
uvcull, samp_order, create_component_file(2)); |
345 |
> |
avgopt, uvcull, samp_order, |
346 |
> |
create_component_file(2)); |
347 |
|
uvfp[1] = popen(cmd, "w"); |
348 |
|
if ((uvfp[0] == NULL) | (uvfp[1] == NULL)) { |
349 |
|
fprintf(stderr, "%s: cannot open pipes to uv output\n", |
375 |
|
fputs("{\n", uvfp[1]); |
376 |
|
} |
377 |
|
} |
378 |
< |
/* need to assign Dx, Dy, Dz? */ |
379 |
< |
if (funame != NULL) |
378 |
> |
if (funame != NULL) /* need to assign Dx, Dy, Dz? */ |
379 |
|
assignD = (fundefined(funame) < 6); |
380 |
|
/* run through directions */ |
381 |
|
for (ix = 0; ix < sqres; ix++) |
397 |
|
eval_rbfcol(&sdv, rbf, iovec+3); |
398 |
|
bsdf = sdv.cieY; |
399 |
|
if (rbf_colorimetry == RBCtristimulus) { |
401 |
– |
c_ccvt(&sdv.spec, C_CSXY); |
400 |
|
uv[0] = uv[1] = 1. / |
401 |
|
(-2.*sdv.spec.cx + 12.*sdv.spec.cy + 3.); |
402 |
|
uv[0] *= 4.*sdv.spec.cx; |
441 |
|
#endif |
442 |
|
} |
443 |
|
if (pctcull >= 0) |
444 |
< |
fwrite(&bsdf, sizeof(bsdf), 1, ofp); |
444 |
> |
putbinary(&bsdf, sizeof(bsdf), 1, ofp); |
445 |
|
else |
446 |
|
fprintf(ofp, "\t%.3e\n", bsdf); |
447 |
|
|
448 |
|
if (rbf_colorimetry == RBCtristimulus) { |
449 |
|
if (pctcull >= 0) { |
450 |
< |
fwrite(&uv[0], sizeof(*uv), 1, uvfp[0]); |
451 |
< |
fwrite(&uv[1], sizeof(*uv), 1, uvfp[1]); |
450 |
> |
putbinary(&uv[0], sizeof(*uv), 1, uvfp[0]); |
451 |
> |
putbinary(&uv[1], sizeof(*uv), 1, uvfp[1]); |
452 |
|
} else { |
453 |
|
fprintf(uvfp[0], "\t%.3e\n", uv[0]); |
454 |
|
fprintf(uvfp[1], "\t%.3e\n", uv[1]); |
461 |
|
free(rbf); |
462 |
|
prog_show((ix*sqres+iy+1.)/(sqres*sqres)); |
463 |
|
} |
464 |
+ |
prog_done(); |
465 |
|
if (pctcull >= 0) { /* finish output */ |
466 |
|
if (pclose(ofp)) { |
467 |
|
fprintf(stderr, "%s: error running rttree_reduce on Y\n", |
491 |
|
} |
492 |
|
} |
493 |
|
} |
495 |
– |
prog_done(); |
494 |
|
} |
495 |
|
|
496 |
< |
#ifdef _WIN32 |
496 |
> |
#if defined(_WIN32) || defined(_WIN64) |
497 |
|
/* Execute wrapBSDF command (may never return) */ |
498 |
|
static int |
499 |
|
wrap_up(void) |