| 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 */ |
| 84 |
|
progname = argv[0]; |
| 85 |
|
/* set up rendering defaults */ |
| 86 |
|
rand_samp = 1; |
| 87 |
< |
dstrsrc = 0.5; |
| 87 |
> |
dstrsrc = 0.65; |
| 88 |
|
srcsizerat = 0.1; |
| 89 |
|
directrelay = 3; |
| 90 |
|
ambounce = 1; |
| 103 |
|
if (!ray_pnprocs) { |
| 104 |
|
over_options(); |
| 105 |
|
if (doheader) { /* print header */ |
| 106 |
+ |
newheader("RADIANCE", stdout); |
| 107 |
|
printargs(argc, argv, stdout); |
| 108 |
|
fputformat("ascii", stdout); |
| 109 |
|
putchar('\n'); |
| 462 |
|
int nt, np; |
| 463 |
|
COLOR vsum; |
| 464 |
|
RAY rr; |
| 465 |
+ |
double sf; |
| 466 |
|
int i, j; |
| 467 |
|
/* set view */ |
| 468 |
|
ourview.type = VT_ANG; |
| 473 |
|
error(USER, err); |
| 474 |
|
/* assign probability table */ |
| 475 |
|
init_ptable(sfile); |
| 476 |
< |
/* do Monte Carlo sampling */ |
| 476 |
> |
/* stratified MC sampling */ |
| 477 |
|
setcolor(vsum, .0f, .0f, .0f); |
| 478 |
|
nt = (int)(sqrt((double)nsamps*ntheta/nphi) + .5); |
| 479 |
|
np = nsamps/nt; |
| 480 |
< |
VCOPY(rr.rorg, ourview.vp); |
| 477 |
< |
rr.rmax = .0; |
| 480 |
> |
sf = gscale/nsamps; |
| 481 |
|
for (i = 0; i < nt; i++) |
| 482 |
|
for (j = 0; j < np; j++) { |
| 483 |
+ |
VCOPY(rr.rorg, ourview.vp); |
| 484 |
|
get_direc(rr.rdir, (i+frandom())/nt, (j+frandom())/np); |
| 485 |
+ |
if (ourview.vfore > FTINY) |
| 486 |
+ |
VSUM(rr.rorg, rr.rorg, rr.rdir, ourview.vfore); |
| 487 |
+ |
rr.rmax = .0; |
| 488 |
|
rayorigin(&rr, PRIMARY, NULL, NULL); |
| 489 |
+ |
scalecolor(rr.rcoef, sf); |
| 490 |
|
if (ray_pqueue(&rr) == 1) |
| 491 |
|
addcolor(vsum, rr.rcol); |
| 492 |
|
} |
| 493 |
< |
/* finish MC calculation */ |
| 494 |
< |
while (ray_presult(&rr, 0) > 0) |
| 495 |
< |
addcolor(vsum, rr.rcol); |
| 496 |
< |
scalecolor(vsum, gscale/(nt*np)); |
| 497 |
< |
/* compute direct component */ |
| 493 |
> |
/* remaining rays pure MC */ |
| 494 |
> |
for (i = nsamps - nt*np; i-- > 0; ) { |
| 495 |
> |
VCOPY(rr.rorg, ourview.vp); |
| 496 |
> |
get_direc(rr.rdir, frandom(), frandom()); |
| 497 |
> |
if (ourview.vfore > FTINY) |
| 498 |
> |
VSUM(rr.rorg, rr.rorg, rr.rdir, ourview.vfore); |
| 499 |
> |
rr.rmax = .0; |
| 500 |
> |
rayorigin(&rr, PRIMARY, NULL, NULL); |
| 501 |
> |
scalecolor(rr.rcoef, sf); |
| 502 |
> |
if (ray_pqueue(&rr) == 1) |
| 503 |
> |
addcolor(vsum, rr.rcol); |
| 504 |
> |
} |
| 505 |
> |
/* scale partial result */ |
| 506 |
> |
scalecolor(vsum, sf); |
| 507 |
> |
/* add direct component */ |
| 508 |
|
for (i = ndirs; i-- > 0; ) { |
| 509 |
|
SRCINDEX si; |
| 510 |
|
initsrcindex(&si); |
| 511 |
|
while (srcray(&rr, NULL, &si)) { |
| 512 |
< |
double d = sens_val(rr.rdir); |
| 513 |
< |
if (d <= FTINY) |
| 512 |
> |
sf = sens_val(rr.rdir); |
| 513 |
> |
if (sf <= FTINY) |
| 514 |
|
continue; |
| 515 |
< |
d *= si.dom/ndirs; |
| 516 |
< |
scalecolor(rr.rcoef, d); |
| 515 |
> |
sf *= si.dom/ndirs; |
| 516 |
> |
scalecolor(rr.rcoef, sf); |
| 517 |
|
if (ray_pqueue(&rr) == 1) { |
| 518 |
|
multcolor(rr.rcol, rr.rcoef); |
| 519 |
|
addcolor(vsum, rr.rcol); |
| 520 |
|
} |
| 521 |
|
} |
| 522 |
|
} |
| 523 |
< |
/* finish direct calculation */ |
| 523 |
> |
/* finish our calculation */ |
| 524 |
|
while (ray_presult(&rr, 0) > 0) { |
| 525 |
|
multcolor(rr.rcol, rr.rcoef); |
| 526 |
|
addcolor(vsum, rr.rcol); |