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, df[2]; |
698 |
+ |
df[0] = PI/4.*dblur*(.5 - frandom())/sqrt(ourview.hn2); |
699 |
+ |
df[1] = PI/4.*dblur*(.5 - frandom())/sqrt(ourview.vn2); |
700 |
+ |
for (i = 3; i--; ) { |
701 |
+ |
vc = thisray.rorg[i] + vdist*thisray.rdir[i]; |
702 |
+ |
thisray.rorg[i] += df[0]*ourview.hvec[i] + |
703 |
+ |
df[1]*ourview.vvec[i] ; |
704 |
+ |
thisray.rdir[i] = vc - thisray.rorg[i]; |
705 |
+ |
} |
706 |
+ |
if (normalize(thisray.rdir) == 0.0) |
707 |
+ |
return(0.0); |
708 |
+ |
} |
709 |
|
|
710 |
|
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
711 |
|
|
776 |
|
error(SYSTEM, errmsg); |
777 |
|
return -1; /* pro forma return */ |
778 |
|
} |
761 |
– |
|
779 |
|
|
780 |
|
static int |
781 |
|
pixnumber( /* compute pixel index (brushed) */ |