9 |
|
|
10 |
|
#include <sys/types.h> |
11 |
|
|
12 |
< |
#ifndef NON_POSIX |
13 |
< |
#ifdef BSD |
14 |
< |
#include <sys/time.h> |
15 |
< |
#include <sys/resource.h> |
12 |
> |
#include "platform.h" |
13 |
> |
#ifdef NON_POSIX |
14 |
> |
#ifdef MINGW |
15 |
> |
#include <sys/time.h> |
16 |
> |
#endif |
17 |
|
#else |
18 |
< |
#include <sys/times.h> |
19 |
< |
#include <unistd.h> |
18 |
> |
#ifdef BSD |
19 |
> |
#include <sys/time.h> |
20 |
> |
#include <sys/resource.h> |
21 |
> |
#else |
22 |
> |
#include <sys/times.h> |
23 |
> |
#include <unistd.h> |
24 |
> |
#endif |
25 |
|
#endif |
20 |
– |
#endif |
26 |
|
|
27 |
|
#include <time.h> |
28 |
|
#include <signal.h> |
29 |
|
|
25 |
– |
#include "platform.h" |
30 |
|
#include "ray.h" |
31 |
|
#include "paths.h" |
32 |
|
#include "ambient.h" |
51 |
|
int ndims = 0; /* number of sampling dimensions */ |
52 |
|
int samplendx; /* sample index number */ |
53 |
|
|
50 |
– |
//extern void ambnotify(); |
54 |
|
void (*addobjnotify[])() = {ambnotify, NULL}; |
55 |
|
|
56 |
|
VIEW ourview = STDVIEW; /* view parameters */ |
64 |
|
|
65 |
|
double mblur = 0.; /* motion blur parameter */ |
66 |
|
|
67 |
+ |
double dblur = 0.; /* depth-of-field blur parameter */ |
68 |
+ |
|
69 |
|
void (*trace)() = NULL; /* trace call */ |
70 |
|
|
71 |
|
int do_irrad = 0; /* compute irradiance? */ |
72 |
|
|
73 |
+ |
int rand_samp = 0; /* pure Monte Carlo sampling? */ |
74 |
+ |
|
75 |
|
double dstrsrc = 0.0; /* square source distribution */ |
76 |
|
double shadthresh = .05; /* shadow threshold */ |
77 |
|
double shadcert = .5; /* shadow certainty */ |
101 |
|
int ambdiv = 512; /* ambient divisions */ |
102 |
|
int ambssamp = 128; /* ambient super-samples */ |
103 |
|
int ambounce = 0; /* ambient bounces */ |
104 |
< |
char *amblist[128]; /* ambient include/exclude list */ |
104 |
> |
char *amblist[AMBLLEN]; /* ambient include/exclude list */ |
105 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
106 |
|
|
107 |
|
int ralrm = 0; /* seconds between reports */ |
118 |
|
|
119 |
|
static VIEW lastview; /* the previous view input */ |
120 |
|
|
114 |
– |
//extern char *mktemp(); /* XXX should be in stdlib.h or unistd.h */ |
115 |
– |
|
116 |
– |
//double pixvalue(); |
117 |
– |
|
121 |
|
static void report(int); |
122 |
|
static int nextview(FILE *fp); |
123 |
|
static void render(char *zfile, char *oldfile); |
665 |
|
{ |
666 |
|
RAY thisray; |
667 |
|
FVECT lorg, ldir; |
668 |
< |
double hpos, vpos, lmax; |
668 |
> |
double hpos, vpos, vdist, lmax; |
669 |
> |
register int i; |
670 |
|
/* compute view ray */ |
671 |
|
hpos = (x+pixjitter())/hres; |
672 |
|
vpos = (y+pixjitter())/vres; |
675 |
|
setcolor(col, 0.0, 0.0, 0.0); |
676 |
|
return(0.0); |
677 |
|
} |
678 |
< |
|
679 |
< |
samplendx = pixnumber(x,y,hres,vres); /* set pixel index */ |
680 |
< |
|
678 |
> |
vdist = ourview.vdist; |
679 |
> |
/* set pixel index */ |
680 |
> |
samplendx = pixnumber(x,y,hres,vres); |
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, dfh, dfv; |
698 |
+ |
/* square/circle conv. */ |
699 |
+ |
dfh = vc = 1. - 2.*frandom(); |
700 |
+ |
dfv = 1. - 2.*frandom(); |
701 |
+ |
dfh *= .5*dblur*sqrt(1. - .5*dfv*dfv); |
702 |
+ |
dfv *= .5*dblur*sqrt(1. - .5*vc*vc); |
703 |
+ |
if (ourview.type == VT_PER || ourview.type == VT_PAR) { |
704 |
+ |
dfh /= sqrt(ourview.hn2); |
705 |
+ |
dfv /= sqrt(ourview.vn2); |
706 |
+ |
for (i = 3; i--; ) { |
707 |
+ |
vc = thisray.rorg[i] + vdist*thisray.rdir[i]; |
708 |
+ |
thisray.rorg[i] += dfh*ourview.hvec[i] + |
709 |
+ |
dfv*ourview.vvec[i] ; |
710 |
+ |
thisray.rdir[i] = vc - thisray.rorg[i]; |
711 |
+ |
} |
712 |
+ |
} else { /* non-standard view case */ |
713 |
+ |
double dfd = PI/4.*dblur*(.5 - frandom()); |
714 |
+ |
if (ourview.type != VT_ANG && ourview.type != VT_PLS) { |
715 |
+ |
if (ourview.type != VT_CYL) |
716 |
+ |
dfh /= sqrt(ourview.hn2); |
717 |
+ |
dfv /= sqrt(ourview.vn2); |
718 |
+ |
} |
719 |
+ |
for (i = 3; i--; ) { |
720 |
+ |
vc = thisray.rorg[i] + vdist*thisray.rdir[i]; |
721 |
+ |
thisray.rorg[i] += dfh*ourview.hvec[i] + |
722 |
+ |
dfv*ourview.vvec[i] + |
723 |
+ |
dfd*ourview.vdir[i] ; |
724 |
+ |
thisray.rdir[i] = vc - thisray.rorg[i]; |
725 |
+ |
} |
726 |
+ |
} |
727 |
+ |
if (normalize(thisray.rdir) == 0.0) |
728 |
+ |
return(0.0); |
729 |
+ |
} |
730 |
|
|
731 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
731 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
732 |
|
|
733 |
|
rayvalue(&thisray); /* trace ray */ |
734 |
|
|
797 |
|
error(SYSTEM, errmsg); |
798 |
|
return -1; /* pro forma return */ |
799 |
|
} |
761 |
– |
|
800 |
|
|
801 |
|
static int |
802 |
|
pixnumber( /* compute pixel index (brushed) */ |