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" |
71 |
|
|
72 |
|
int do_irrad = 0; /* compute irradiance? */ |
73 |
|
|
74 |
+ |
int rand_samp = 0; /* pure Monte Carlo sampling? */ |
75 |
+ |
|
76 |
|
double dstrsrc = 0.0; /* square source distribution */ |
77 |
|
double shadthresh = .05; /* shadow threshold */ |
78 |
|
double shadcert = .5; /* shadow certainty */ |
681 |
|
return(0.0); |
682 |
|
} |
683 |
|
vdist = ourview.vdist; |
684 |
< |
|
685 |
< |
samplendx = pixnumber(x,y,hres,vres); /* set pixel index */ |
680 |
< |
|
684 |
> |
/* set pixel index */ |
685 |
> |
samplendx = pixnumber(x,y,hres,vres); |
686 |
|
/* optional motion blur */ |
687 |
|
if (lastview.type && mblur > FTINY && (lmax = viewray(lorg, ldir, |
688 |
|
&lastview, hpos, vpos)) >= -FTINY) { |
699 |
|
} |
700 |
|
/* optional depth-of-field */ |
701 |
|
if (dblur > FTINY && vdist > FTINY) { |
702 |
< |
double vc, df[2]; |
703 |
< |
df[0] = PI/4.*dblur*(.5 - frandom())/sqrt(ourview.hn2); |
704 |
< |
df[1] = PI/4.*dblur*(.5 - frandom())/sqrt(ourview.vn2); |
705 |
< |
for (i = 3; i--; ) { |
706 |
< |
vc = thisray.rorg[i] + 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]; |
702 |
> |
double vc, dfh, dfv; |
703 |
> |
/* square/circle conv. */ |
704 |
> |
dfh = vc = 1. - 2.*frandom(); |
705 |
> |
dfv = 1. - 2.*frandom(); |
706 |
> |
dfh *= .5*dblur*sqrt(1. - .5*dfv*dfv); |
707 |
> |
dfv *= .5*dblur*sqrt(1. - .5*vc*vc); |
708 |
> |
if (ourview.type == VT_PER || ourview.type == VT_PAR) { |
709 |
> |
dfh /= sqrt(ourview.hn2); |
710 |
> |
dfv /= sqrt(ourview.vn2); |
711 |
> |
for (i = 3; i--; ) { |
712 |
> |
vc = thisray.rorg[i] + vdist*thisray.rdir[i]; |
713 |
> |
thisray.rorg[i] += dfh*ourview.hvec[i] + |
714 |
> |
dfv*ourview.vvec[i] ; |
715 |
> |
thisray.rdir[i] = vc - thisray.rorg[i]; |
716 |
> |
} |
717 |
> |
} else { /* non-standard view case */ |
718 |
> |
double dfd = PI/4.*dblur*(.5 - frandom()); |
719 |
> |
if (ourview.type != VT_ANG && ourview.type != VT_PLS) { |
720 |
> |
if (ourview.type != VT_CYL) |
721 |
> |
dfh /= sqrt(ourview.hn2); |
722 |
> |
dfv /= sqrt(ourview.vn2); |
723 |
> |
} |
724 |
> |
for (i = 3; i--; ) { |
725 |
> |
vc = thisray.rorg[i] + vdist*thisray.rdir[i]; |
726 |
> |
thisray.rorg[i] += dfh*ourview.hvec[i] + |
727 |
> |
dfv*ourview.vvec[i] + |
728 |
> |
dfd*ourview.vdir[i] ; |
729 |
> |
thisray.rdir[i] = vc - thisray.rorg[i]; |
730 |
> |
} |
731 |
|
} |
732 |
|
if (normalize(thisray.rdir) == 0.0) |
733 |
|
return(0.0); |
734 |
|
} |
735 |
|
|
736 |
< |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
736 |
> |
rayorigin(&thisray, PRIMARY, NULL, NULL); |
737 |
|
|
738 |
|
rayvalue(&thisray); /* trace ray */ |
739 |
|
|