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; |
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++) { |
250 |
|
#endif |
251 |
|
} |
252 |
|
if (pctcull >= 0) |
253 |
< |
fwrite(&bsdf, sizeof(bsdf), 1, ofp); |
253 |
> |
putbinary(&bsdf, sizeof(bsdf), 1, ofp); |
254 |
|
else |
255 |
|
fprintf(ofp, "\t%.3e\n", bsdf); |
256 |
|
|
257 |
|
if (rbf_colorimetry == RBCtristimulus) { |
258 |
|
if (pctcull >= 0) { |
259 |
< |
fwrite(&uv[0], sizeof(*uv), 1, uvfp[0]); |
260 |
< |
fwrite(&uv[1], sizeof(*uv), 1, uvfp[1]); |
259 |
> |
putbinary(&uv[0], sizeof(*uv), 1, uvfp[0]); |
260 |
> |
putbinary(&uv[1], sizeof(*uv), 1, uvfp[1]); |
261 |
|
} else { |
262 |
|
fprintf(uvfp[0], "\t%.3e\n", uv[0]); |
263 |
|
fprintf(uvfp[1], "\t%.3e\n", uv[1]); |
270 |
|
free(rbf); |
271 |
|
prog_show((ix+1.)*(2./sqres)); |
272 |
|
} |
273 |
+ |
prog_done(); |
274 |
|
if (pctcull >= 0) { /* finish output */ |
275 |
|
if (pclose(ofp)) { |
276 |
|
fprintf(stderr, "%s: error running rttree_reduce on Y\n", |
306 |
|
} |
307 |
|
} |
308 |
|
} |
309 |
– |
prog_done(); |
309 |
|
} |
310 |
|
|
311 |
|
/* Interpolate and output anisotropic BSDF data */ |
321 |
|
float bsdf, uv[2]; |
322 |
|
|
323 |
|
if (pctcull >= 0) { |
324 |
+ |
const char *avgopt = (input_orient>0 ^ output_orient>0) |
325 |
+ |
? "" : " -a"; |
326 |
|
sprintf(cmd, "rttree_reduce%s -h -ff -r 4 -t %f -g %d > %s", |
327 |
< |
(input_orient>0 ^ output_orient>0) ? "" : " -a", |
328 |
< |
pctcull, samp_order, create_component_file(0)); |
327 |
> |
avgopt, pctcull, samp_order, |
328 |
> |
create_component_file(0)); |
329 |
|
ofp = popen(cmd, "w"); |
330 |
|
if (ofp == NULL) { |
331 |
|
fprintf(stderr, "%s: cannot create pipe to rttree_reduce\n", |
339 |
|
if (rbf_colorimetry == RBCtristimulus) { |
340 |
|
double uvcull = 100. - (100.-pctcull)*.25; |
341 |
|
sprintf(cmd, "rttree_reduce%s -h -ff -r 4 -t %f -g %d > %s", |
342 |
< |
(input_orient>0 ^ output_orient>0) ? "" : " -a", |
343 |
< |
uvcull, samp_order, create_component_file(1)); |
342 |
> |
avgopt, uvcull, samp_order, |
343 |
> |
create_component_file(1)); |
344 |
|
uvfp[0] = popen(cmd, "w"); |
345 |
|
sprintf(cmd, "rttree_reduce%s -h -ff -r 4 -t %f -g %d > %s", |
346 |
< |
(input_orient>0 ^ output_orient>0) ? "" : " -a", |
347 |
< |
uvcull, samp_order, create_component_file(2)); |
346 |
> |
avgopt, uvcull, samp_order, |
347 |
> |
create_component_file(2)); |
348 |
|
uvfp[1] = popen(cmd, "w"); |
349 |
|
if ((uvfp[0] == NULL) | (uvfp[1] == NULL)) { |
350 |
|
fprintf(stderr, "%s: cannot open pipes to uv output\n", |
376 |
|
fputs("{\n", uvfp[1]); |
377 |
|
} |
378 |
|
} |
379 |
< |
/* need to assign Dx, Dy, Dz? */ |
379 |
< |
if (funame != NULL) |
379 |
> |
if (funame != NULL) /* need to assign Dx, Dy, Dz? */ |
380 |
|
assignD = (fundefined(funame) < 6); |
381 |
|
/* run through directions */ |
382 |
|
for (ix = 0; ix < sqres; ix++) |
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]); |
463 |
|
free(rbf); |
464 |
|
prog_show((ix*sqres+iy+1.)/(sqres*sqres)); |
465 |
|
} |
466 |
+ |
prog_done(); |
467 |
|
if (pctcull >= 0) { /* finish output */ |
468 |
|
if (pclose(ofp)) { |
469 |
|
fprintf(stderr, "%s: error running rttree_reduce on Y\n", |
493 |
|
} |
494 |
|
} |
495 |
|
} |
495 |
– |
prog_done(); |
496 |
|
} |
497 |
|
|
498 |
< |
#ifdef _WIN32 |
498 |
> |
#if defined(_WIN32) || defined(_WIN64) |
499 |
|
/* Execute wrapBSDF command (may never return) */ |
500 |
|
static int |
501 |
|
wrap_up(void) |