662 |
|
{ |
663 |
|
RAY thisray; |
664 |
|
FVECT lorg, ldir; |
665 |
< |
double hpos, vpos, vdist, lmax; |
665 |
> |
double hpos, vpos, lmax; |
666 |
|
int i; |
667 |
|
/* compute view ray */ |
668 |
|
setcolor(col, 0.0, 0.0, 0.0); |
671 |
|
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, |
672 |
|
&ourview, hpos, vpos)) < -FTINY) |
673 |
|
return(0.0); |
674 |
– |
|
675 |
– |
vdist = ourview.vdist; |
674 |
|
/* set pixel index */ |
675 |
|
samplendx = pixnumber(x,y,hres,vres); |
676 |
|
/* optional motion blur */ |
685 |
|
} |
686 |
|
if (normalize(thisray.rdir) == 0.0) |
687 |
|
return(0.0); |
690 |
– |
vdist = (1.-d)*vdist + d*lastview.vdist; |
688 |
|
} |
689 |
< |
/* optional depth-of-field */ |
690 |
< |
if (dblur > FTINY) { |
691 |
< |
double vc, df[2]; |
695 |
< |
/* random point on disk */ |
696 |
< |
SDsquare2disk(df, frandom(), frandom()); |
697 |
< |
df[0] *= .5*dblur; |
698 |
< |
df[1] *= .5*dblur; |
699 |
< |
if ((ourview.type == VT_PER) | (ourview.type == VT_PAR)) { |
700 |
< |
double adj = 1.0; |
701 |
< |
if (ourview.type == VT_PER) |
702 |
< |
adj /= DOT(thisray.rdir, ourview.vdir); |
703 |
< |
df[0] /= sqrt(ourview.hn2); |
704 |
< |
df[1] /= sqrt(ourview.vn2); |
705 |
< |
for (i = 3; i--; ) { |
706 |
< |
vc = ourview.vp[i] + adj*vdist*thisray.rdir[i]; |
707 |
< |
thisray.rorg[i] += df[0]*ourview.hvec[i] + |
708 |
< |
df[1]*ourview.vvec[i] ; |
709 |
< |
thisray.rdir[i] = vc - thisray.rorg[i]; |
710 |
< |
} |
711 |
< |
} else { /* non-standard view case */ |
712 |
< |
double dfd = PI/4.*dblur*(.5 - frandom()); |
713 |
< |
if ((ourview.type != VT_ANG) & (ourview.type != VT_PLS)) { |
714 |
< |
if (ourview.type != VT_CYL) |
715 |
< |
df[0] /= sqrt(ourview.hn2); |
716 |
< |
df[1] /= sqrt(ourview.vn2); |
717 |
< |
} |
718 |
< |
for (i = 3; i--; ) { |
719 |
< |
vc = ourview.vp[i] + vdist*thisray.rdir[i]; |
720 |
< |
thisray.rorg[i] += df[0]*ourview.hvec[i] + |
721 |
< |
df[1]*ourview.vvec[i] + |
722 |
< |
dfd*ourview.vdir[i] ; |
723 |
< |
thisray.rdir[i] = vc - thisray.rorg[i]; |
724 |
< |
} |
725 |
< |
} |
726 |
< |
if (normalize(thisray.rdir) == 0.0) |
727 |
< |
return(0.0); |
728 |
< |
} |
689 |
> |
/* depth-of-field */ |
690 |
> |
if (!jitteraperture(thisray.rorg, thisray.rdir, &ourview, dblur)) |
691 |
> |
return(0.0); |
692 |
|
|
693 |
|
rayorigin(&thisray, PRIMARY, NULL, NULL); |
694 |
|
|