71 |
|
print_rdefaults(); |
72 |
|
} |
73 |
|
|
74 |
+ |
|
75 |
+ |
void |
76 |
+ |
quit(ec) /* make sure exit is called */ |
77 |
+ |
int ec; |
78 |
+ |
{ |
79 |
+ |
if (ray_pnprocs > 0) /* close children if any */ |
80 |
+ |
ray_pclose(0); |
81 |
+ |
exit(ec); |
82 |
+ |
} |
83 |
+ |
|
84 |
+ |
|
85 |
|
int |
86 |
|
main( |
87 |
|
int argc, |
95 |
|
progname = argv[0]; |
96 |
|
/* set up rendering defaults */ |
97 |
|
rand_samp = 1; |
98 |
< |
dstrsrc = 0.5; |
98 |
> |
dstrsrc = 0.65; |
99 |
|
srcsizerat = 0.1; |
100 |
|
directrelay = 3; |
101 |
|
ambounce = 1; |
114 |
|
if (!ray_pnprocs) { |
115 |
|
over_options(); |
116 |
|
if (doheader) { /* print header */ |
117 |
+ |
newheader("RADIANCE", stdout); |
118 |
|
printargs(argc, argv, stdout); |
119 |
|
fputformat("ascii", stdout); |
120 |
|
putchar('\n'); |
121 |
|
} |
122 |
|
/* start process(es) */ |
123 |
< |
ray_pinit(argv[argc-1], nprocs); |
123 |
> |
if (strcmp(argv[argc-1], ".")) |
124 |
> |
ray_pinit(argv[argc-1], nprocs); |
125 |
|
} |
126 |
|
comp_sensor(argv[i]); /* process a sensor file */ |
127 |
|
continue; |
195 |
|
} |
196 |
|
i += rval; |
197 |
|
} |
198 |
< |
if (!ray_pnprocs) |
198 |
> |
if (sensor == NULL) |
199 |
|
error(USER, i<argc ? "missing sensor file" : "missing octree"); |
200 |
|
quit(0); |
201 |
|
} |
462 |
|
return(s_val(t,p)); |
463 |
|
} |
464 |
|
|
465 |
+ |
/* Print origin and direction */ |
466 |
+ |
static void |
467 |
+ |
print_ray( |
468 |
+ |
FVECT rorg, |
469 |
+ |
FVECT rdir |
470 |
+ |
) |
471 |
+ |
{ |
472 |
+ |
printf("%.6g %.6g %.6g %.8f %.8f %.8f\n", |
473 |
+ |
rorg[0], rorg[1], rorg[2], |
474 |
+ |
rdir[0], rdir[1], rdir[2]); |
475 |
+ |
} |
476 |
+ |
|
477 |
|
/* Compute sensor output */ |
478 |
|
static void |
479 |
|
comp_sensor( |
486 |
|
int nt, np; |
487 |
|
COLOR vsum; |
488 |
|
RAY rr; |
489 |
+ |
double sf; |
490 |
|
int i, j; |
491 |
|
/* set view */ |
492 |
|
ourview.type = VT_ANG; |
497 |
|
error(USER, err); |
498 |
|
/* assign probability table */ |
499 |
|
init_ptable(sfile); |
500 |
< |
/* do Monte Carlo sampling */ |
500 |
> |
/* stratified MC sampling */ |
501 |
|
setcolor(vsum, .0f, .0f, .0f); |
502 |
|
nt = (int)(sqrt((double)nsamps*ntheta/nphi) + .5); |
503 |
|
np = nsamps/nt; |
504 |
+ |
sf = gscale/nsamps; |
505 |
|
for (i = 0; i < nt; i++) |
506 |
|
for (j = 0; j < np; j++) { |
507 |
|
VCOPY(rr.rorg, ourview.vp); |
508 |
|
get_direc(rr.rdir, (i+frandom())/nt, (j+frandom())/np); |
509 |
|
if (ourview.vfore > FTINY) |
510 |
|
VSUM(rr.rorg, rr.rorg, rr.rdir, ourview.vfore); |
511 |
+ |
if (!ray_pnprocs) { |
512 |
+ |
print_ray(rr.rorg, rr.rdir); |
513 |
+ |
continue; |
514 |
+ |
} |
515 |
|
rr.rmax = .0; |
516 |
|
rayorigin(&rr, PRIMARY, NULL, NULL); |
517 |
+ |
scalecolor(rr.rcoef, sf); |
518 |
|
if (ray_pqueue(&rr) == 1) |
519 |
|
addcolor(vsum, rr.rcol); |
520 |
|
} |
521 |
< |
/* finish MC calculation */ |
522 |
< |
while (ray_presult(&rr, 0) > 0) |
523 |
< |
addcolor(vsum, rr.rcol); |
524 |
< |
scalecolor(vsum, gscale/(nt*np)); |
525 |
< |
/* compute direct component */ |
521 |
> |
/* remaining rays pure MC */ |
522 |
> |
for (i = nsamps - nt*np; i-- > 0; ) { |
523 |
> |
VCOPY(rr.rorg, ourview.vp); |
524 |
> |
get_direc(rr.rdir, frandom(), frandom()); |
525 |
> |
if (ourview.vfore > FTINY) |
526 |
> |
VSUM(rr.rorg, rr.rorg, rr.rdir, ourview.vfore); |
527 |
> |
if (!ray_pnprocs) { |
528 |
> |
print_ray(rr.rorg, rr.rdir); |
529 |
> |
continue; |
530 |
> |
} |
531 |
> |
rr.rmax = .0; |
532 |
> |
rayorigin(&rr, PRIMARY, NULL, NULL); |
533 |
> |
scalecolor(rr.rcoef, sf); |
534 |
> |
if (ray_pqueue(&rr) == 1) |
535 |
> |
addcolor(vsum, rr.rcol); |
536 |
> |
} |
537 |
> |
if (!ray_pnprocs) /* just printing rays */ |
538 |
> |
return; |
539 |
> |
/* scale partial result */ |
540 |
> |
scalecolor(vsum, sf); |
541 |
> |
/* add direct component */ |
542 |
|
for (i = ndirs; i-- > 0; ) { |
543 |
|
SRCINDEX si; |
544 |
|
initsrcindex(&si); |
545 |
|
while (srcray(&rr, NULL, &si)) { |
546 |
< |
double d = sens_val(rr.rdir); |
547 |
< |
if (d <= FTINY) |
546 |
> |
sf = sens_val(rr.rdir); |
547 |
> |
if (sf <= FTINY) |
548 |
|
continue; |
549 |
< |
d *= si.dom/ndirs; |
550 |
< |
scalecolor(rr.rcoef, d); |
549 |
> |
sf *= si.dom/ndirs; |
550 |
> |
scalecolor(rr.rcoef, sf); |
551 |
|
if (ray_pqueue(&rr) == 1) { |
552 |
|
multcolor(rr.rcol, rr.rcoef); |
553 |
|
addcolor(vsum, rr.rcol); |
554 |
|
} |
555 |
|
} |
556 |
|
} |
557 |
< |
/* finish direct calculation */ |
557 |
> |
/* finish our calculation */ |
558 |
|
while (ray_presult(&rr, 0) > 0) { |
559 |
|
multcolor(rr.rcol, rr.rcoef); |
560 |
|
addcolor(vsum, rr.rcol); |