33 |
|
#include "view.h" |
34 |
|
#include "random.h" |
35 |
|
#include "paths.h" |
36 |
< |
#include "rtmisc.h" /* myhostname() */ |
36 |
> |
#include "hilbert.h" |
37 |
> |
#include "pmapbias.h" |
38 |
> |
#include "pmapdiag.h" |
39 |
|
|
38 |
– |
|
40 |
|
#define RFTEMPLATE "rfXXXXXX" |
41 |
|
|
42 |
|
#ifndef SIGCONT |
168 |
|
static void |
169 |
|
report(int dummy) /* report progress */ |
170 |
|
{ |
171 |
< |
double u, s; |
171 |
> |
char bcStat [128]; |
172 |
> |
double u, s; |
173 |
|
#ifdef BSD |
174 |
< |
struct rusage rubuf; |
174 |
> |
struct rusage rubuf; |
175 |
|
#else |
176 |
< |
struct tms tbuf; |
177 |
< |
double period; |
176 |
> |
double period = 1.0 / 60.0; |
177 |
> |
struct tms tbuf; |
178 |
|
#endif |
179 |
|
|
180 |
|
tlastrept = time((time_t *)NULL); |
181 |
|
#ifdef BSD |
182 |
|
getrusage(RUSAGE_SELF, &rubuf); |
183 |
< |
u = rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec/1e6; |
184 |
< |
s = rubuf.ru_stime.tv_sec + rubuf.ru_stime.tv_usec/1e6; |
183 |
> |
u = rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec*1e-6; |
184 |
> |
s = rubuf.ru_stime.tv_sec + rubuf.ru_stime.tv_usec*1e-6; |
185 |
|
getrusage(RUSAGE_CHILDREN, &rubuf); |
186 |
< |
u += rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec/1e6; |
187 |
< |
s += rubuf.ru_stime.tv_sec + rubuf.ru_stime.tv_usec/1e6; |
186 |
> |
u += rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec*1e-6; |
187 |
> |
s += rubuf.ru_stime.tv_sec + rubuf.ru_stime.tv_usec*1e-6; |
188 |
|
#else |
189 |
|
times(&tbuf); |
190 |
|
#ifdef _SC_CLK_TCK |
191 |
|
period = 1.0 / sysconf(_SC_CLK_TCK); |
190 |
– |
#else |
191 |
– |
period = 1.0 / 60.0; |
192 |
|
#endif |
193 |
|
u = ( tbuf.tms_utime + tbuf.tms_cutime ) * period; |
194 |
|
s = ( tbuf.tms_stime + tbuf.tms_cstime ) * period; |
195 |
|
#endif |
196 |
|
|
197 |
+ |
/* PMAP: Get photon map bias compensation statistics */ |
198 |
+ |
pmapBiasCompReport(bcStat); |
199 |
+ |
|
200 |
|
sprintf(errmsg, |
201 |
< |
"%lu rays, %4.2f%% after %.3fu %.3fs %.3fr hours on %s\n", |
202 |
< |
nrays, pctdone, u/3600., s/3600., |
203 |
< |
(tlastrept-tstart)/3600., myhostname()); |
201 |
> |
"%lu rays, %s%4.2f%% after %.3fu %.3fs %.3fr hours on %s (PID %d)\n", |
202 |
> |
nrays, bcStat, pctdone, u*(1./3600.), s*(1./3600.), |
203 |
> |
(tlastrept-tstart)*(1./3600.), myhostname(), getpid()); |
204 |
|
eputs(errmsg); |
205 |
|
#ifdef SIGCONT |
206 |
|
signal(SIGCONT, report); |
210 |
|
static void |
211 |
|
report(int dummy) /* report progress */ |
212 |
|
{ |
213 |
+ |
char bcStat [128]; |
214 |
+ |
|
215 |
|
tlastrept = time((time_t *)NULL); |
216 |
< |
sprintf(errmsg, "%lu rays, %4.2f%% after %5.4f hours\n", |
217 |
< |
nrays, pctdone, (tlastrept-tstart)/3600.0); |
216 |
> |
|
217 |
> |
/* PMAP: Get photon map bias compensation statistics */ |
218 |
> |
pmapBiasCompReport(bcStat); |
219 |
> |
|
220 |
> |
sprintf(errmsg, "%lu rays, %s%4.2f%% after %5.4f hours\n", |
221 |
> |
nrays, bcStat, pctdone, (tlastrept-tstart)/3600.0); |
222 |
|
eputs(errmsg); |
223 |
|
} |
224 |
|
#endif |
225 |
|
|
226 |
|
|
227 |
< |
extern void |
227 |
> |
void |
228 |
|
rpict( /* generate image(s) */ |
229 |
|
int seq, |
230 |
|
char *pout, |
672 |
|
int y |
673 |
|
) |
674 |
|
{ |
675 |
+ |
extern void SDsquare2disk(double ds[2], double seedx, double seedy); |
676 |
|
RAY thisray; |
677 |
|
FVECT lorg, ldir; |
678 |
|
double hpos, vpos, vdist, lmax; |
704 |
|
} |
705 |
|
/* optional depth-of-field */ |
706 |
|
if (dblur > FTINY) { |
707 |
< |
double vc, dfh, dfv; |
708 |
< |
/* square/circle conv. */ |
709 |
< |
dfh = vc = 1. - 2.*frandom(); |
710 |
< |
dfv = 1. - 2.*frandom(); |
711 |
< |
dfh *= .5*dblur*sqrt(1. - .5*dfv*dfv); |
702 |
< |
dfv *= .5*dblur*sqrt(1. - .5*vc*vc); |
707 |
> |
double vc, df[2]; |
708 |
> |
/* random point on disk */ |
709 |
> |
SDsquare2disk(df, frandom(), frandom()); |
710 |
> |
df[0] *= .5*dblur; |
711 |
> |
df[1] *= .5*dblur; |
712 |
|
if ((ourview.type == VT_PER) | (ourview.type == VT_PAR)) { |
713 |
|
double adj = 1.0; |
714 |
|
if (ourview.type == VT_PER) |
715 |
|
adj /= DOT(thisray.rdir, ourview.vdir); |
716 |
< |
dfh /= sqrt(ourview.hn2); |
717 |
< |
dfv /= sqrt(ourview.vn2); |
716 |
> |
df[0] /= sqrt(ourview.hn2); |
717 |
> |
df[1] /= sqrt(ourview.vn2); |
718 |
|
for (i = 3; i--; ) { |
719 |
|
vc = ourview.vp[i] + adj*vdist*thisray.rdir[i]; |
720 |
< |
thisray.rorg[i] += dfh*ourview.hvec[i] + |
721 |
< |
dfv*ourview.vvec[i] ; |
720 |
> |
thisray.rorg[i] += df[0]*ourview.hvec[i] + |
721 |
> |
df[1]*ourview.vvec[i] ; |
722 |
|
thisray.rdir[i] = vc - thisray.rorg[i]; |
723 |
|
} |
724 |
|
} else { /* non-standard view case */ |
725 |
|
double dfd = PI/4.*dblur*(.5 - frandom()); |
726 |
|
if ((ourview.type != VT_ANG) & (ourview.type != VT_PLS)) { |
727 |
|
if (ourview.type != VT_CYL) |
728 |
< |
dfh /= sqrt(ourview.hn2); |
729 |
< |
dfv /= sqrt(ourview.vn2); |
728 |
> |
df[0] /= sqrt(ourview.hn2); |
729 |
> |
df[1] /= sqrt(ourview.vn2); |
730 |
|
} |
731 |
|
for (i = 3; i--; ) { |
732 |
|
vc = ourview.vp[i] + vdist*thisray.rdir[i]; |
733 |
< |
thisray.rorg[i] += dfh*ourview.hvec[i] + |
734 |
< |
dfv*ourview.vvec[i] + |
733 |
> |
thisray.rorg[i] += df[0]*ourview.hvec[i] + |
734 |
> |
df[1]*ourview.vvec[i] + |
735 |
|
dfd*ourview.vdir[i] ; |
736 |
|
thisray.rdir[i] = vc - thisray.rorg[i]; |
737 |
|
} |
811 |
|
} |
812 |
|
|
813 |
|
static int |
814 |
< |
pixnumber( /* compute pixel index (brushed) */ |
814 |
> |
pixnumber( /* compute pixel index (screen door) */ |
815 |
|
int x, |
816 |
|
int y, |
817 |
|
int xres, |
818 |
|
int yres |
819 |
|
) |
820 |
|
{ |
821 |
< |
x -= y; |
822 |
< |
while (x < 0) |
823 |
< |
x += xres; |
824 |
< |
return((((x>>2)*yres + y) << 2) + (x & 3)); |
821 |
> |
unsigned nbits = 0; |
822 |
> |
bitmask_t coord[2]; |
823 |
> |
|
824 |
> |
if (xres < yres) xres = yres; |
825 |
> |
while (xres > 0) { |
826 |
> |
xres >>= 1; |
827 |
> |
++nbits; |
828 |
> |
} |
829 |
> |
coord[0] = x; coord[1] = y; |
830 |
> |
return ((int)hilbert_c2i(2, nbits, coord)); |
831 |
|
} |