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? */ |
664 |
|
{ |
665 |
|
RAY thisray; |
666 |
|
FVECT lorg, ldir; |
667 |
< |
double hpos, vpos, lmax; |
667 |
> |
double hpos, vpos, vdist, lmax; |
668 |
> |
register int i; |
669 |
|
/* compute view ray */ |
670 |
|
hpos = (x+pixjitter())/hres; |
671 |
|
vpos = (y+pixjitter())/vres; |
674 |
|
setcolor(col, 0.0, 0.0, 0.0); |
675 |
|
return(0.0); |
676 |
|
} |
677 |
+ |
vdist = ourview.vdist; |
678 |
|
|
679 |
|
samplendx = pixnumber(x,y,hres,vres); /* set pixel index */ |
680 |
|
|
681 |
|
/* optional motion blur */ |
682 |
|
if (lastview.type && mblur > FTINY && (lmax = viewray(lorg, ldir, |
683 |
|
&lastview, hpos, vpos)) >= -FTINY) { |
680 |
– |
register int i; |
684 |
|
register double d = mblur*(.5-urand(281+samplendx)); |
685 |
|
|
686 |
|
thisray.rmax = (1.-d)*thisray.rmax + d*lmax; |
690 |
|
} |
691 |
|
if (normalize(thisray.rdir) == 0.0) |
692 |
|
return(0.0); |
693 |
+ |
vdist = (1.-d)*vdist + d*lastview.vdist; |
694 |
|
} |
695 |
+ |
/* optional depth-of-field */ |
696 |
+ |
if (dblur > FTINY && vdist > FTINY) { |
697 |
+ |
double vc, dfh, dfv; |
698 |
+ |
/* PI/4. square/circle conv. */ |
699 |
+ |
dfh = PI/4.*dblur*(.5 - frandom()); |
700 |
+ |
dfv = PI/4.*dblur*(.5 - frandom()); |
701 |
+ |
if (ourview.type == VT_PER || ourview.type == VT_PAR) { |
702 |
+ |
dfh /= sqrt(ourview.hn2); |
703 |
+ |
dfv /= sqrt(ourview.vn2); |
704 |
+ |
for (i = 3; i--; ) { |
705 |
+ |
vc = thisray.rorg[i] + vdist*thisray.rdir[i]; |
706 |
+ |
thisray.rorg[i] += dfh*ourview.hvec[i] + |
707 |
+ |
dfv*ourview.vvec[i] ; |
708 |
+ |
thisray.rdir[i] = vc - thisray.rorg[i]; |
709 |
+ |
} |
710 |
+ |
} else { /* non-standard view case */ |
711 |
+ |
double dfd = PI/4.*dblur*(.5 - frandom()); |
712 |
+ |
if (ourview.type != VT_ANG) { |
713 |
+ |
if (ourview.type != VT_CYL) |
714 |
+ |
dfh /= sqrt(ourview.hn2); |
715 |
+ |
dfv /= sqrt(ourview.vn2); |
716 |
+ |
} |
717 |
+ |
for (i = 3; i--; ) { |
718 |
+ |
vc = thisray.rorg[i] + vdist*thisray.rdir[i]; |
719 |
+ |
thisray.rorg[i] += dfh*ourview.hvec[i] + |
720 |
+ |
dfv*ourview.vvec[i] + |
721 |
+ |
dfd*ourview.vdir[i] ; |
722 |
+ |
thisray.rdir[i] = vc - thisray.rorg[i]; |
723 |
+ |
} |
724 |
+ |
} |
725 |
+ |
if (normalize(thisray.rdir) == 0.0) |
726 |
+ |
return(0.0); |
727 |
+ |
} |
728 |
|
|
729 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
729 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
730 |
|
|
731 |
|
rayvalue(&thisray); /* trace ray */ |
732 |
|
|
795 |
|
error(SYSTEM, errmsg); |
796 |
|
return -1; /* pro forma return */ |
797 |
|
} |
761 |
– |
|
798 |
|
|
799 |
|
static int |
800 |
|
pixnumber( /* compute pixel index (brushed) */ |