22 |
|
extern int nowarn; /* don't report warnings? */ |
23 |
|
|
24 |
|
/* current sensor's perspective */ |
25 |
< |
VIEW ourview = STDVIEW; |
25 |
> |
VIEW ourview = {VT_ANG,{0.,0.,0.},{0.,0.,1.},{1.,0.,0.}, |
26 |
> |
1.,180.,180.,0.,0.,0.,0., |
27 |
> |
{0.,0.,0.},{0.,0.,0.},0.,0.}; |
28 |
|
|
29 |
|
unsigned long nsamps = 10000; /* desired number of initial samples */ |
30 |
|
unsigned long nssamps = 9000; /* number of super-samples */ |
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'); |
473 |
|
int nt, np; |
474 |
|
COLOR vsum; |
475 |
|
RAY rr; |
476 |
+ |
double sf; |
477 |
|
int i, j; |
478 |
|
/* set view */ |
479 |
|
ourview.type = VT_ANG; |
484 |
|
error(USER, err); |
485 |
|
/* assign probability table */ |
486 |
|
init_ptable(sfile); |
487 |
< |
/* do Monte Carlo sampling */ |
487 |
> |
/* stratified MC sampling */ |
488 |
|
setcolor(vsum, .0f, .0f, .0f); |
489 |
|
nt = (int)(sqrt((double)nsamps*ntheta/nphi) + .5); |
490 |
|
np = nsamps/nt; |
491 |
< |
VCOPY(rr.rorg, ourview.vp); |
477 |
< |
rr.rmax = .0; |
491 |
> |
sf = gscale/nsamps; |
492 |
|
for (i = 0; i < nt; i++) |
493 |
|
for (j = 0; j < np; j++) { |
494 |
+ |
VCOPY(rr.rorg, ourview.vp); |
495 |
|
get_direc(rr.rdir, (i+frandom())/nt, (j+frandom())/np); |
496 |
+ |
if (ourview.vfore > FTINY) |
497 |
+ |
VSUM(rr.rorg, rr.rorg, rr.rdir, ourview.vfore); |
498 |
+ |
rr.rmax = .0; |
499 |
|
rayorigin(&rr, PRIMARY, NULL, NULL); |
500 |
+ |
scalecolor(rr.rcoef, sf); |
501 |
|
if (ray_pqueue(&rr) == 1) |
502 |
|
addcolor(vsum, rr.rcol); |
503 |
|
} |
504 |
< |
/* finish MC calculation */ |
505 |
< |
while (ray_presult(&rr, 0) > 0) |
506 |
< |
addcolor(vsum, rr.rcol); |
507 |
< |
scalecolor(vsum, gscale/(nt*np)); |
508 |
< |
/* compute direct component */ |
504 |
> |
/* remaining rays pure MC */ |
505 |
> |
for (i = nsamps - nt*np; i-- > 0; ) { |
506 |
> |
VCOPY(rr.rorg, ourview.vp); |
507 |
> |
get_direc(rr.rdir, frandom(), frandom()); |
508 |
> |
if (ourview.vfore > FTINY) |
509 |
> |
VSUM(rr.rorg, rr.rorg, rr.rdir, ourview.vfore); |
510 |
> |
rr.rmax = .0; |
511 |
> |
rayorigin(&rr, PRIMARY, NULL, NULL); |
512 |
> |
scalecolor(rr.rcoef, sf); |
513 |
> |
if (ray_pqueue(&rr) == 1) |
514 |
> |
addcolor(vsum, rr.rcol); |
515 |
> |
} |
516 |
> |
/* scale partial result */ |
517 |
> |
scalecolor(vsum, sf); |
518 |
> |
/* add direct component */ |
519 |
|
for (i = ndirs; i-- > 0; ) { |
520 |
|
SRCINDEX si; |
521 |
|
initsrcindex(&si); |
522 |
|
while (srcray(&rr, NULL, &si)) { |
523 |
< |
double d = sens_val(rr.rdir); |
524 |
< |
if (d <= FTINY) |
523 |
> |
sf = sens_val(rr.rdir); |
524 |
> |
if (sf <= FTINY) |
525 |
|
continue; |
526 |
< |
d *= si.dom/ndirs; |
527 |
< |
scalecolor(rr.rcoef, d); |
526 |
> |
sf *= si.dom/ndirs; |
527 |
> |
scalecolor(rr.rcoef, sf); |
528 |
|
if (ray_pqueue(&rr) == 1) { |
529 |
|
multcolor(rr.rcol, rr.rcoef); |
530 |
|
addcolor(vsum, rr.rcol); |
531 |
|
} |
532 |
|
} |
533 |
|
} |
534 |
< |
/* finish direct calculation */ |
534 |
> |
/* finish our calculation */ |
535 |
|
while (ray_presult(&rr, 0) > 0) { |
536 |
|
multcolor(rr.rcol, rr.rcoef); |
537 |
|
addcolor(vsum, rr.rcol); |