--- ray/src/rt/rpict.c 2004/03/30 16:13:01 2.69 +++ ray/src/rt/rpict.c 2005/01/18 00:33:16 2.73 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id"; +static const char RCSid[] = "$Id: rpict.c,v 2.73 2005/01/18 00:33:16 greg Exp $"; #endif /* * rpict.c - routines and variables for picture generation. @@ -61,6 +61,8 @@ double dstrpix = 0.67; /* square pixel distribution double mblur = 0.; /* motion blur parameter */ +double dblur = 0.; /* depth-of-field blur parameter */ + void (*trace)() = NULL; /* trace call */ int do_irrad = 0; /* compute irradiance? */ @@ -94,7 +96,7 @@ int ambres = 64; /* ambient resolution */ int ambdiv = 512; /* ambient divisions */ int ambssamp = 128; /* ambient super-samples */ int ambounce = 0; /* ambient bounces */ -char *amblist[128]; /* ambient include/exclude list */ +char *amblist[AMBLLEN]; /* ambient include/exclude list */ int ambincl = -1; /* include == 1, exclude == 0 */ int ralrm = 0; /* seconds between reports */ @@ -202,7 +204,7 @@ report(int dummy) /* report progress */ } #else static void -report(int) /* report progress */ +report(int dummy) /* report progress */ { tlastrept = time((time_t *)NULL); sprintf(errmsg, "%lu rays, %4.2f%% after %5.4f hours\n", @@ -662,7 +664,8 @@ pixvalue( /* compute pixel value */ { RAY thisray; FVECT lorg, ldir; - double hpos, vpos, lmax; + double hpos, vpos, vdist, lmax; + register int i; /* compute view ray */ hpos = (x+pixjitter())/hres; vpos = (y+pixjitter())/vres; @@ -671,13 +674,13 @@ pixvalue( /* compute pixel value */ setcolor(col, 0.0, 0.0, 0.0); return(0.0); } + vdist = ourview.vdist; samplendx = pixnumber(x,y,hres,vres); /* set pixel index */ /* optional motion blur */ if (lastview.type && mblur > FTINY && (lmax = viewray(lorg, ldir, &lastview, hpos, vpos)) >= -FTINY) { - register int i; register double d = mblur*(.5-urand(281+samplendx)); thisray.rmax = (1.-d)*thisray.rmax + d*lmax; @@ -687,7 +690,22 @@ pixvalue( /* compute pixel value */ } if (normalize(thisray.rdir) == 0.0) return(0.0); + vdist = (1.-d)*vdist + d*lastview.vdist; } + /* optional depth-of-field */ + if (dblur > FTINY && vdist > FTINY) { + double vc, df[2]; + df[0] = PI/4.*dblur*(.5 - frandom())/sqrt(ourview.hn2); + df[1] = PI/4.*dblur*(.5 - frandom())/sqrt(ourview.vn2); + for (i = 3; i--; ) { + vc = thisray.rorg[i] + vdist*thisray.rdir[i]; + thisray.rorg[i] += df[0]*ourview.hvec[i] + + df[1]*ourview.vvec[i] ; + thisray.rdir[i] = vc - thisray.rorg[i]; + } + if (normalize(thisray.rdir) == 0.0) + return(0.0); + } rayorigin(&thisray, NULL, PRIMARY, 1.0); @@ -758,7 +776,6 @@ writerr: error(SYSTEM, errmsg); return -1; /* pro forma return */ } - static int pixnumber( /* compute pixel index (brushed) */