25 |
|
/* sampling order */ |
26 |
|
static int samp_order = 6; |
27 |
|
/* super-sampling threshold */ |
28 |
< |
const double ssamp_thresh = 0.35; |
28 |
> |
static double ssamp_thresh = 0.35; |
29 |
|
/* number of super-samples */ |
30 |
|
#ifndef NSSAMP |
31 |
< |
#define NSSAMP 64 |
31 |
> |
#define NSSAMP 256 |
32 |
|
#endif |
33 |
|
/* limit on number of RBF lobes */ |
34 |
|
static int lobe_lim = 15000; |
129 |
|
{ |
130 |
|
const int sqres = 1<<samp_order; |
131 |
|
const double sqfact = 1./(double)sqres; |
132 |
+ |
float *ryval = NULL; |
133 |
+ |
char *rtrip = NULL; |
134 |
|
FILE *ofp, *uvfp[2]; |
135 |
|
int assignD = 0; |
136 |
|
char cmd[128]; |
191 |
|
} |
192 |
|
if (funame != NULL) /* need to assign Dx, Dy, Dz? */ |
193 |
|
assignD = (fundefined(funame) < 6); |
194 |
+ |
#if (NSSAMP > 0) |
195 |
+ |
rtrip = (char *)calloc(sqres, 1); /* track sample triggerings */ |
196 |
+ |
ryval = (float *)calloc(sqres, sizeof(float)); |
197 |
+ |
#endif |
198 |
|
/* run through directions */ |
199 |
|
for (ix = 0; ix < sqres/2; ix++) { |
200 |
|
const int zipsgn = (ix & 1)*2 - 1; |
206 |
|
if (funame == NULL) |
207 |
|
rbf = advect_rbf(iovec, lobe_lim); |
208 |
|
for (ox = 0; ox < sqres; ox++) { |
209 |
< |
float last_bsdf = -1; |
209 |
> |
SDValue sdv_next; |
210 |
> |
SDsquare2disk(iovec+3, (ox+.5)*sqfact, .5*sqfact); |
211 |
> |
iovec[5] = output_orient * |
212 |
> |
sqrt(1. - iovec[3]*iovec[3] - iovec[4]*iovec[4]); |
213 |
> |
if (funame == NULL) { |
214 |
> |
eval_rbfcol(&sdv_next, rbf, iovec+3); |
215 |
> |
} else { |
216 |
> |
sdv_next.spec = c_dfcolor; |
217 |
> |
if (assignD) { |
218 |
> |
varset("Dx", '=', -iovec[3]); |
219 |
> |
varset("Dy", '=', -iovec[4]); |
220 |
> |
varset("Dz", '=', -iovec[5]); |
221 |
> |
++eclock; |
222 |
> |
} |
223 |
> |
sdv_next.cieY = funvalue(funame, 6, iovec); |
224 |
> |
} |
225 |
|
for (oy = 0; oy < sqres; oy++) { |
226 |
< |
SDsquare2disk(iovec+3, (ox+.5)*sqfact, (oy+.5)*sqfact); |
227 |
< |
iovec[5] = output_orient * |
226 |
> |
int trip; |
227 |
> |
bsdf = sdv_next.cieY; /* keeping one step ahead... */ |
228 |
> |
if (oy < sqres-1) { |
229 |
> |
SDsquare2disk(iovec+3, (ox+.5)*sqfact, (oy+1.5)*sqfact); |
230 |
> |
iovec[5] = output_orient * |
231 |
|
sqrt(1. - iovec[3]*iovec[3] - iovec[4]*iovec[4]); |
232 |
+ |
} |
233 |
|
if (funame == NULL) { |
234 |
< |
SDValue sdv; |
235 |
< |
eval_rbfcol(&sdv, rbf, iovec+3); |
236 |
< |
bsdf = sdv.cieY; |
234 |
> |
SDValue sdv = sdv_next; |
235 |
> |
if (oy < sqres-1) |
236 |
> |
eval_rbfcol(&sdv_next, rbf, iovec+3); |
237 |
|
#if (NSSAMP > 0) |
238 |
< |
if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) { |
238 |
> |
trip = (abs_diff(bsdf, sdv_next.cieY) > ssamp_thresh || |
239 |
> |
(ox && abs_diff(bsdf, ryval[oy]) > ssamp_thresh) || |
240 |
> |
(oy && abs_diff(bsdf, ryval[oy-1]) > ssamp_thresh)); |
241 |
> |
if (trip | rtrip[oy] || (oy && rtrip[oy-1])) { |
242 |
|
int ssi; |
243 |
|
double ssa[2], sum = 0, usum = 0, vsum = 0; |
244 |
|
/* super-sample voxel */ |
272 |
|
uv[1] *= 9.*sdv.spec.cy; |
273 |
|
} |
274 |
|
} else { |
275 |
< |
if (assignD) { |
276 |
< |
varset("Dx", '=', -iovec[3]); |
277 |
< |
varset("Dy", '=', -iovec[4]); |
278 |
< |
varset("Dz", '=', -iovec[5]); |
279 |
< |
++eclock; |
275 |
> |
if (oy < sqres-1) { |
276 |
> |
if (assignD) { |
277 |
> |
varset("Dx", '=', -iovec[3]); |
278 |
> |
varset("Dy", '=', -iovec[4]); |
279 |
> |
varset("Dz", '=', -iovec[5]); |
280 |
> |
++eclock; |
281 |
> |
} |
282 |
> |
sdv_next.cieY = funvalue(funame, 6, iovec); |
283 |
|
} |
253 |
– |
bsdf = funvalue(funame, 6, iovec); |
284 |
|
#if (NSSAMP > 0) |
285 |
< |
if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) { |
285 |
> |
trip = (abs_diff(bsdf, sdv_next.cieY) > ssamp_thresh || |
286 |
> |
(ox && abs_diff(bsdf, ryval[oy]) > ssamp_thresh) || |
287 |
> |
(oy && abs_diff(bsdf, ryval[oy-1]) > ssamp_thresh)); |
288 |
> |
if (trip | rtrip[oy] || (oy && rtrip[oy-1])) { |
289 |
|
int ssi; |
290 |
|
double ssa[4], ssvec[6], sum = 0; |
291 |
|
/* super-sample voxel */ |
332 |
|
fprintf(uvfp[1], "\t%.3e\n", uv[1]); |
333 |
|
} |
334 |
|
} |
335 |
< |
last_bsdf = bsdf; |
335 |
> |
if (ryval != NULL) { |
336 |
> |
rtrip[oy] = trip; |
337 |
> |
ryval[oy] = bsdf; |
338 |
> |
} |
339 |
|
} |
340 |
|
} |
341 |
|
if (rbf != NULL) |
343 |
|
prog_show((ix+1.)*(2.*sqfact)); |
344 |
|
} |
345 |
|
prog_done(); |
346 |
+ |
if (ryval != NULL) { |
347 |
+ |
free(rtrip); |
348 |
+ |
free(ryval); |
349 |
+ |
} |
350 |
|
if (pctcull >= 0) { /* finish output */ |
351 |
|
if (pclose(ofp)) { |
352 |
|
fprintf(stderr, "%s: error running rttree_reduce on Y\n", |
390 |
|
{ |
391 |
|
const int sqres = 1<<samp_order; |
392 |
|
const double sqfact = 1./(double)sqres; |
393 |
+ |
float *ryval = NULL; |
394 |
+ |
char *rtrip = NULL; |
395 |
|
FILE *ofp, *uvfp[2]; |
396 |
|
int assignD = 0; |
397 |
|
char cmd[128]; |
457 |
|
} |
458 |
|
if (funame != NULL) /* need to assign Dx, Dy, Dz? */ |
459 |
|
assignD = (fundefined(funame) < 6); |
460 |
+ |
#if (NSSAMP > 0) |
461 |
+ |
rtrip = (char *)calloc(sqres, 1); /* track sample triggerings */ |
462 |
+ |
ryval = (float *)calloc(sqres, sizeof(float)); |
463 |
+ |
#endif |
464 |
|
/* run through directions */ |
465 |
|
for (ix = 0; ix < sqres; ix++) |
466 |
|
for (iy = 0; iy < sqres; iy++) { |
471 |
|
if (funame == NULL) |
472 |
|
rbf = advect_rbf(iovec, lobe_lim); |
473 |
|
for (ox = 0; ox < sqres; ox++) { |
474 |
< |
float last_bsdf = -1; |
474 |
> |
SDValue sdv_next; |
475 |
> |
SDsquare2disk(iovec+3, (ox+.5)*sqfact, .5*sqfact); |
476 |
> |
iovec[5] = output_orient * |
477 |
> |
sqrt(1. - iovec[3]*iovec[3] - iovec[4]*iovec[4]); |
478 |
> |
if (funame == NULL) { |
479 |
> |
eval_rbfcol(&sdv_next, rbf, iovec+3); |
480 |
> |
} else { |
481 |
> |
sdv_next.spec = c_dfcolor; |
482 |
> |
if (assignD) { |
483 |
> |
varset("Dx", '=', -iovec[3]); |
484 |
> |
varset("Dy", '=', -iovec[4]); |
485 |
> |
varset("Dz", '=', -iovec[5]); |
486 |
> |
++eclock; |
487 |
> |
} |
488 |
> |
sdv_next.cieY = funvalue(funame, 6, iovec); |
489 |
> |
} |
490 |
|
for (oy = 0; oy < sqres; oy++) { |
491 |
< |
SDsquare2disk(iovec+3, (ox+.5)*sqfact, (oy+.5)*sqfact); |
492 |
< |
iovec[5] = output_orient * |
491 |
> |
int trip; |
492 |
> |
bsdf = sdv_next.cieY; /* keeping one step ahead... */ |
493 |
> |
if (oy < sqres-1) { |
494 |
> |
SDsquare2disk(iovec+3, (ox+.5)*sqfact, (oy+1.5)*sqfact); |
495 |
> |
iovec[5] = output_orient * |
496 |
|
sqrt(1. - iovec[3]*iovec[3] - iovec[4]*iovec[4]); |
497 |
+ |
} |
498 |
|
if (funame == NULL) { |
499 |
< |
SDValue sdv; |
500 |
< |
eval_rbfcol(&sdv, rbf, iovec+3); |
501 |
< |
bsdf = sdv.cieY; |
499 |
> |
SDValue sdv = sdv_next; |
500 |
> |
if (oy < sqres-1) |
501 |
> |
eval_rbfcol(&sdv_next, rbf, iovec+3); |
502 |
|
#if (NSSAMP > 0) |
503 |
< |
if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) { |
503 |
> |
trip = (abs_diff(bsdf, sdv_next.cieY) > ssamp_thresh || |
504 |
> |
(ox && abs_diff(bsdf, ryval[oy]) > ssamp_thresh) || |
505 |
> |
(oy && abs_diff(bsdf, ryval[oy-1]) > ssamp_thresh)); |
506 |
> |
if (trip | rtrip[oy] || (oy && rtrip[oy-1])) { |
507 |
|
int ssi; |
508 |
|
double ssa[2], sum = 0, usum = 0, vsum = 0; |
509 |
|
/* super-sample voxel */ |
537 |
|
uv[1] *= 9.*sdv.spec.cy; |
538 |
|
} |
539 |
|
} else { |
540 |
< |
if (assignD) { |
541 |
< |
varset("Dx", '=', -iovec[3]); |
542 |
< |
varset("Dy", '=', -iovec[4]); |
543 |
< |
varset("Dz", '=', -iovec[5]); |
544 |
< |
++eclock; |
540 |
> |
if (oy < sqres-1) { |
541 |
> |
if (assignD) { |
542 |
> |
varset("Dx", '=', -iovec[3]); |
543 |
> |
varset("Dy", '=', -iovec[4]); |
544 |
> |
varset("Dz", '=', -iovec[5]); |
545 |
> |
++eclock; |
546 |
> |
} |
547 |
> |
sdv_next.cieY = funvalue(funame, 6, iovec); |
548 |
|
} |
478 |
– |
bsdf = funvalue(funame, 6, iovec); |
549 |
|
#if (NSSAMP > 0) |
550 |
< |
if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) { |
550 |
> |
trip = (abs_diff(bsdf, sdv_next.cieY) > ssamp_thresh || |
551 |
> |
(ox && abs_diff(bsdf, ryval[oy]) > ssamp_thresh) || |
552 |
> |
(oy && abs_diff(bsdf, ryval[oy-1]) > ssamp_thresh)); |
553 |
> |
if (trip | rtrip[oy] || (oy && rtrip[oy-1])) { |
554 |
|
int ssi; |
555 |
|
double ssa[4], ssvec[6], sum = 0; |
556 |
|
/* super-sample voxel */ |
593 |
|
fprintf(uvfp[1], "\t%.3e\n", uv[1]); |
594 |
|
} |
595 |
|
} |
596 |
< |
last_bsdf = bsdf; |
596 |
> |
if (ryval != NULL) { |
597 |
> |
rtrip[oy] = trip; |
598 |
> |
ryval[oy] = bsdf; |
599 |
> |
} |
600 |
|
} |
525 |
– |
} |
601 |
|
if (rbf != NULL) |
602 |
|
free(rbf); |
603 |
|
prog_show((ix*sqres+iy+1.)/(sqres*sqres)); |
604 |
|
} |
605 |
+ |
} |
606 |
|
prog_done(); |
607 |
+ |
if (ryval != NULL) { |
608 |
+ |
free(rtrip); |
609 |
+ |
free(ryval); |
610 |
+ |
} |
611 |
|
if (pctcull >= 0) { /* finish output */ |
612 |
|
if (pclose(ofp)) { |
613 |
|
fprintf(stderr, "%s: error running rttree_reduce on Y\n", |
713 |
|
switch (argv[i][1]) { /* get options */ |
714 |
|
case 'e': |
715 |
|
scompile(argv[++i], NULL, 0); |
716 |
+ |
if (single_plane_incident < 0) |
717 |
+ |
single_plane_incident = 0; |
718 |
|
break; |
719 |
|
case 'f': |
720 |
|
if (!argv[i][2]) { |
793 |
|
goto userr; |
794 |
|
} |
795 |
|
++eclock; |
796 |
+ |
ssamp_thresh *= 0.5; /* lower sampling threshold */ |
797 |
|
add_wbsdf("-a", 1); |
798 |
|
add_wbsdf(tfmt[single_plane_incident], 1); |
799 |
|
if (dofwd) { |