61 |
|
|
62 |
|
double mblur = 0.; /* motion blur parameter */ |
63 |
|
|
64 |
+ |
double dblur = 0.; /* depth-of-field blur parameter */ |
65 |
+ |
|
66 |
|
void (*trace)() = NULL; /* trace call */ |
67 |
|
|
68 |
|
int do_irrad = 0; /* compute irradiance? */ |
69 |
|
|
70 |
+ |
int rand_samp = 0; /* pure Monte Carlo sampling? */ |
71 |
+ |
|
72 |
|
double dstrsrc = 0.0; /* square source distribution */ |
73 |
|
double shadthresh = .05; /* shadow threshold */ |
74 |
|
double shadcert = .5; /* shadow certainty */ |
98 |
|
int ambdiv = 512; /* ambient divisions */ |
99 |
|
int ambssamp = 128; /* ambient super-samples */ |
100 |
|
int ambounce = 0; /* ambient bounces */ |
101 |
< |
char *amblist[128]; /* ambient include/exclude list */ |
101 |
> |
char *amblist[AMBLLEN]; /* ambient include/exclude list */ |
102 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
103 |
|
|
104 |
|
int ralrm = 0; /* seconds between reports */ |
666 |
|
{ |
667 |
|
RAY thisray; |
668 |
|
FVECT lorg, ldir; |
669 |
< |
double hpos, vpos, lmax; |
669 |
> |
double hpos, vpos, vdist, lmax; |
670 |
> |
register int i; |
671 |
|
/* compute view ray */ |
672 |
|
hpos = (x+pixjitter())/hres; |
673 |
|
vpos = (y+pixjitter())/vres; |
676 |
|
setcolor(col, 0.0, 0.0, 0.0); |
677 |
|
return(0.0); |
678 |
|
} |
679 |
+ |
vdist = ourview.vdist; |
680 |
|
|
681 |
< |
samplendx = pixnumber(x,y,hres,vres); /* set pixel index */ |
681 |
> |
if (rand_samp) /* set pixel index */ |
682 |
> |
samplendx = random(); |
683 |
> |
else |
684 |
> |
samplendx = pixnumber(x,y,hres,vres); |
685 |
|
|
686 |
|
/* optional motion blur */ |
687 |
|
if (lastview.type && mblur > FTINY && (lmax = viewray(lorg, ldir, |
688 |
|
&lastview, hpos, vpos)) >= -FTINY) { |
680 |
– |
register int i; |
689 |
|
register double d = mblur*(.5-urand(281+samplendx)); |
690 |
|
|
691 |
|
thisray.rmax = (1.-d)*thisray.rmax + d*lmax; |
695 |
|
} |
696 |
|
if (normalize(thisray.rdir) == 0.0) |
697 |
|
return(0.0); |
698 |
+ |
vdist = (1.-d)*vdist + d*lastview.vdist; |
699 |
|
} |
700 |
+ |
/* optional depth-of-field */ |
701 |
+ |
if (dblur > FTINY && vdist > FTINY) { |
702 |
+ |
double vc, dfh, dfv; |
703 |
+ |
/* PI/4. square/circle conv. */ |
704 |
+ |
dfh = PI/4.*dblur*(.5 - frandom()); |
705 |
+ |
dfv = PI/4.*dblur*(.5 - frandom()); |
706 |
+ |
if (ourview.type == VT_PER || ourview.type == VT_PAR) { |
707 |
+ |
dfh /= sqrt(ourview.hn2); |
708 |
+ |
dfv /= sqrt(ourview.vn2); |
709 |
+ |
for (i = 3; i--; ) { |
710 |
+ |
vc = thisray.rorg[i] + vdist*thisray.rdir[i]; |
711 |
+ |
thisray.rorg[i] += dfh*ourview.hvec[i] + |
712 |
+ |
dfv*ourview.vvec[i] ; |
713 |
+ |
thisray.rdir[i] = vc - thisray.rorg[i]; |
714 |
+ |
} |
715 |
+ |
} else { /* non-standard view case */ |
716 |
+ |
double dfd = PI/4.*dblur*(.5 - frandom()); |
717 |
+ |
if (ourview.type != VT_ANG) { |
718 |
+ |
if (ourview.type != VT_CYL) |
719 |
+ |
dfh /= sqrt(ourview.hn2); |
720 |
+ |
dfv /= sqrt(ourview.vn2); |
721 |
+ |
} |
722 |
+ |
for (i = 3; i--; ) { |
723 |
+ |
vc = thisray.rorg[i] + vdist*thisray.rdir[i]; |
724 |
+ |
thisray.rorg[i] += dfh*ourview.hvec[i] + |
725 |
+ |
dfv*ourview.vvec[i] + |
726 |
+ |
dfd*ourview.vdir[i] ; |
727 |
+ |
thisray.rdir[i] = vc - thisray.rorg[i]; |
728 |
+ |
} |
729 |
+ |
} |
730 |
+ |
if (normalize(thisray.rdir) == 0.0) |
731 |
+ |
return(0.0); |
732 |
+ |
} |
733 |
|
|
734 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
734 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
735 |
|
|
736 |
|
rayvalue(&thisray); /* trace ray */ |
737 |
|
|
800 |
|
error(SYSTEM, errmsg); |
801 |
|
return -1; /* pro forma return */ |
802 |
|
} |
761 |
– |
|
803 |
|
|
804 |
|
static int |
805 |
|
pixnumber( /* compute pixel index (brushed) */ |