--- ray/src/rt/rpict.c 2005/02/07 20:13:55 2.74 +++ ray/src/rt/rpict.c 2011/02/25 06:51:50 2.84 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rpict.c,v 2.74 2005/02/07 20:13:55 greg Exp $"; +static const char RCSid[] = "$Id: rpict.c,v 2.84 2011/02/25 06:51:50 greg Exp $"; #endif /* * rpict.c - routines and variables for picture generation. @@ -9,20 +9,24 @@ static const char RCSid[] = "$Id: rpict.c,v 2.74 2005/ #include -#ifndef NON_POSIX -#ifdef BSD -#include -#include +#include "platform.h" +#ifdef NON_POSIX + #ifdef MINGW + #include + #endif #else -#include -#include + #ifdef BSD + #include + #include + #else + #include + #include + #endif #endif -#endif #include #include -#include "platform.h" #include "ray.h" #include "paths.h" #include "ambient.h" @@ -47,7 +51,6 @@ int dimlist[MAXDIM]; /* sampling dimensions */ int ndims = 0; /* number of sampling dimensions */ int samplendx; /* sample index number */ -//extern void ambnotify(); void (*addobjnotify[])() = {ambnotify, NULL}; VIEW ourview = STDVIEW; /* view parameters */ @@ -67,6 +70,8 @@ void (*trace)() = NULL; /* trace call */ int do_irrad = 0; /* compute irradiance? */ +int rand_samp = 0; /* pure Monte Carlo sampling? */ + double dstrsrc = 0.0; /* square source distribution */ double shadthresh = .05; /* shadow threshold */ double shadcert = .5; /* shadow certainty */ @@ -86,7 +91,7 @@ double specjitter = 1.; /* specular sampling jitter * int backvis = 1; /* back face visibility */ int maxdepth = 7; /* maximum recursion depth */ -double minweight = 4e-3; /* minimum ray weight */ +double minweight = 1e-3; /* minimum ray weight */ char *ambfile = NULL; /* ambient file name */ COLOR ambval = BLKCOLOR; /* ambient value */ @@ -113,10 +118,6 @@ int hres, vres; /* resolution for this frame */ static VIEW lastview; /* the previous view input */ -//extern char *mktemp(); /* XXX should be in stdlib.h or unistd.h */ - -//double pixvalue(); - static void report(int); static int nextview(FILE *fp); static void render(char *zfile, char *oldfile); @@ -675,9 +676,8 @@ pixvalue( /* compute pixel value */ return(0.0); } vdist = ourview.vdist; - - samplendx = pixnumber(x,y,hres,vres); /* set pixel index */ - + /* set pixel index */ + samplendx = pixnumber(x,y,hres,vres); /* optional motion blur */ if (lastview.type && mblur > FTINY && (lmax = viewray(lorg, ldir, &lastview, hpos, vpos)) >= -FTINY) { @@ -695,9 +695,11 @@ pixvalue( /* compute pixel value */ /* optional depth-of-field */ if (dblur > FTINY && vdist > FTINY) { double vc, dfh, dfv; - /* PI/4. square/circle conv. */ - dfh = PI/4.*dblur*(.5 - frandom()); - dfv = PI/4.*dblur*(.5 - frandom()); + /* square/circle conv. */ + dfh = vc = 1. - 2.*frandom(); + dfv = 1. - 2.*frandom(); + dfh *= .5*dblur*sqrt(1. - .5*dfv*dfv); + dfv *= .5*dblur*sqrt(1. - .5*vc*vc); if (ourview.type == VT_PER || ourview.type == VT_PAR) { dfh /= sqrt(ourview.hn2); dfv /= sqrt(ourview.vn2); @@ -709,7 +711,7 @@ pixvalue( /* compute pixel value */ } } else { /* non-standard view case */ double dfd = PI/4.*dblur*(.5 - frandom()); - if (ourview.type != VT_ANG) { + if (ourview.type != VT_ANG && ourview.type != VT_PLS) { if (ourview.type != VT_CYL) dfh /= sqrt(ourview.hn2); dfv /= sqrt(ourview.vn2); @@ -726,7 +728,7 @@ pixvalue( /* compute pixel value */ return(0.0); } - rayorigin(&thisray, NULL, PRIMARY, 1.0); + rayorigin(&thisray, PRIMARY, NULL, NULL); rayvalue(&thisray); /* trace ray */