663 |
|
int y |
664 |
|
) |
665 |
|
{ |
666 |
+ |
extern void SDsquare2disk(double ds[2], double seedx, double seedy); |
667 |
|
RAY thisray; |
668 |
|
FVECT lorg, ldir; |
669 |
|
double hpos, vpos, vdist, lmax; |
695 |
|
} |
696 |
|
/* optional depth-of-field */ |
697 |
|
if (dblur > FTINY) { |
698 |
< |
double vc, dfh, dfv; |
699 |
< |
/* square/circle conv. */ |
700 |
< |
dfh = vc = 1. - 2.*frandom(); |
701 |
< |
dfv = 1. - 2.*frandom(); |
702 |
< |
dfh *= .5*dblur*sqrt(1. - .5*dfv*dfv); |
702 |
< |
dfv *= .5*dblur*sqrt(1. - .5*vc*vc); |
698 |
> |
double vc, df[2]; |
699 |
> |
/* random point on disk */ |
700 |
> |
SDsquare2disk(df, frandom(), frandom()); |
701 |
> |
df[0] *= .5*dblur; |
702 |
> |
df[1] *= .5*dblur; |
703 |
|
if ((ourview.type == VT_PER) | (ourview.type == VT_PAR)) { |
704 |
|
double adj = 1.0; |
705 |
|
if (ourview.type == VT_PER) |
706 |
|
adj /= DOT(thisray.rdir, ourview.vdir); |
707 |
< |
dfh /= sqrt(ourview.hn2); |
708 |
< |
dfv /= sqrt(ourview.vn2); |
707 |
> |
df[0] /= sqrt(ourview.hn2); |
708 |
> |
df[1] /= sqrt(ourview.vn2); |
709 |
|
for (i = 3; i--; ) { |
710 |
|
vc = ourview.vp[i] + adj*vdist*thisray.rdir[i]; |
711 |
< |
thisray.rorg[i] += dfh*ourview.hvec[i] + |
712 |
< |
dfv*ourview.vvec[i] ; |
711 |
> |
thisray.rorg[i] += df[0]*ourview.hvec[i] + |
712 |
> |
df[1]*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) & (ourview.type != VT_PLS)) { |
718 |
|
if (ourview.type != VT_CYL) |
719 |
< |
dfh /= sqrt(ourview.hn2); |
720 |
< |
dfv /= sqrt(ourview.vn2); |
719 |
> |
df[0] /= sqrt(ourview.hn2); |
720 |
> |
df[1] /= sqrt(ourview.vn2); |
721 |
|
} |
722 |
|
for (i = 3; i--; ) { |
723 |
|
vc = ourview.vp[i] + vdist*thisray.rdir[i]; |
724 |
< |
thisray.rorg[i] += dfh*ourview.hvec[i] + |
725 |
< |
dfv*ourview.vvec[i] + |
724 |
> |
thisray.rorg[i] += df[0]*ourview.hvec[i] + |
725 |
> |
df[1]*ourview.vvec[i] + |
726 |
|
dfd*ourview.vdir[i] ; |
727 |
|
thisray.rdir[i] = vc - thisray.rorg[i]; |
728 |
|
} |