18 |
|
#endif |
19 |
|
|
20 |
|
#include <signal.h> |
21 |
– |
#include <fcntl.h> |
21 |
|
|
22 |
|
#include "view.h" |
23 |
|
|
25 |
|
|
26 |
|
#include "random.h" |
27 |
|
|
28 |
+ |
#include "paths.h" |
29 |
+ |
|
30 |
|
int dimlist[MAXDIM]; /* sampling dimensions */ |
31 |
|
int ndims = 0; /* number of sampling dimensions */ |
32 |
|
int samplendx; /* sample index number */ |
34 |
|
VIEW ourview = STDVIEW; /* view parameters */ |
35 |
|
int hresolu = 512; /* horizontal resolution */ |
36 |
|
int vresolu = 512; /* vertical resolution */ |
37 |
< |
double pixaspect = 1.0; /* pixel aspect ratio */ |
37 |
> |
double pixaspect = 1.0; /* pixel aspect ratio */ |
38 |
|
|
39 |
|
int psample = 4; /* pixel sample size */ |
40 |
< |
double maxdiff = .05; /* max. difference for interpolation */ |
41 |
< |
double dstrpix = 0.67; /* square pixel distribution */ |
40 |
> |
double maxdiff = .05; /* max. difference for interpolation */ |
41 |
> |
double dstrpix = 0.67; /* square pixel distribution */ |
42 |
|
|
43 |
< |
double dstrsrc = 0.0; /* square source distribution */ |
44 |
< |
double shadthresh = .05; /* shadow threshold */ |
45 |
< |
double shadcert = .5; /* shadow certainty */ |
43 |
> |
double dstrsrc = 0.0; /* square source distribution */ |
44 |
> |
double shadthresh = .05; /* shadow threshold */ |
45 |
> |
double shadcert = .5; /* shadow certainty */ |
46 |
|
int directrelay = 1; /* number of source relays */ |
47 |
|
int vspretest = 512; /* virtual source pretest density */ |
48 |
|
int directinvis = 0; /* sources invisible? */ |
49 |
< |
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
49 |
> |
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
50 |
|
|
51 |
< |
double specthresh = .15; /* specular sampling threshold */ |
52 |
< |
double specjitter = 1.; /* specular sampling jitter */ |
51 |
> |
double specthresh = .15; /* specular sampling threshold */ |
52 |
> |
double specjitter = 1.; /* specular sampling jitter */ |
53 |
|
|
54 |
|
int maxdepth = 6; /* maximum recursion depth */ |
55 |
< |
double minweight = 5e-3; /* minimum ray weight */ |
55 |
> |
double minweight = 5e-3; /* minimum ray weight */ |
56 |
|
|
57 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
58 |
< |
double ambacc = 0.2; /* ambient accuracy */ |
58 |
> |
double ambacc = 0.2; /* ambient accuracy */ |
59 |
|
int ambres = 32; /* ambient resolution */ |
60 |
|
int ambdiv = 128; /* ambient divisions */ |
61 |
|
int ambssamp = 0; /* ambient super-samples */ |
63 |
|
char *amblist[128]; /* ambient include/exclude list */ |
64 |
|
int ambincl = -1; /* include == 1, exclude == 0 */ |
65 |
|
|
66 |
+ |
#ifdef MSDOS |
67 |
+ |
int ralrm = 60; /* seconds between reports */ |
68 |
+ |
#else |
69 |
|
int ralrm = 0; /* seconds between reports */ |
70 |
+ |
#endif |
71 |
|
|
72 |
< |
double pctdone = 0.0; /* percentage done */ |
72 |
> |
double pctdone = 0.0; /* percentage done */ |
73 |
|
|
74 |
|
long tlastrept = 0L; /* time at last report */ |
75 |
|
|
78 |
|
|
79 |
|
extern long nrays; /* number of rays traced */ |
80 |
|
|
81 |
< |
#define MAXDIV 16 /* maximum sample size */ |
81 |
> |
#define MAXDIV 16 /* maximum sample size */ |
82 |
|
|
83 |
< |
#define pixjitter() (.5+dstrpix*(.5-frandom())) |
83 |
> |
#define pixjitter() (.5+dstrpix*(.5-frandom())) |
84 |
|
|
85 |
< |
#define RFTEMPLATE "rfXXXXXX" |
86 |
< |
#define HFTEMPLATE "/tmp/hfXXXXXX" |
85 |
> |
#define RFTEMPLATE "rfXXXXXX" |
86 |
> |
#define HFTEMPLATE TEMPLATE |
87 |
|
|
88 |
|
static char *hfname = NULL; /* header file name */ |
89 |
|
static FILE *hfp = NULL; /* header file pointer */ |
92 |
|
|
93 |
|
extern char *mktemp(); |
94 |
|
|
95 |
< |
double pixvalue(); |
95 |
> |
double pixvalue(); |
96 |
|
|
97 |
|
|
98 |
|
quit(code) /* quit program */ |
113 |
|
report() /* report progress */ |
114 |
|
{ |
115 |
|
struct rusage rubuf; |
116 |
< |
double t; |
116 |
> |
double t; |
117 |
|
|
118 |
|
getrusage(RUSAGE_SELF, &rubuf); |
119 |
|
t = (rubuf.ru_utime.tv_usec + rubuf.ru_stime.tv_usec) / 1e6; |
187 |
|
extern char *rindex(), *strncpy(), *strcat(); |
188 |
|
char fbuf[128], fbuf2[128]; |
189 |
|
register char *cp; |
190 |
< |
RESOLU rs; |
191 |
< |
double pa; |
190 |
> |
RESOLU rs; |
191 |
> |
double pa; |
192 |
|
/* finished writing header */ |
193 |
|
closeheader(); |
194 |
|
/* check sampling */ |
352 |
|
pctdone = 100.0*i/vres; |
353 |
|
if (ralrm > 0) /* report init stats */ |
354 |
|
report(); |
355 |
< |
#ifndef BSD |
355 |
> |
#ifndef BSD |
356 |
|
else |
357 |
|
#endif |
358 |
|
signal(SIGALRM, report); |
377 |
|
/* fill bar */ |
378 |
|
fillscanbar(scanbar, zbar, hres, ypos, ystep); |
379 |
|
/* write it out */ |
380 |
< |
#ifndef BSD |
380 |
> |
#ifndef BSD |
381 |
|
signal(SIGALRM, SIG_IGN); /* don't interrupt writes */ |
382 |
|
#endif |
383 |
|
for (i = ystep; i > 0; i--) { |
394 |
|
pctdone = 100.0*(vres-1-ypos)/vres; |
395 |
|
if (ralrm > 0 && time((long *)0) >= tlastrept+ralrm) |
396 |
|
report(); |
397 |
< |
#ifndef BSD |
397 |
> |
#ifndef BSD |
398 |
|
else |
399 |
|
signal(SIGALRM, report); |
400 |
|
#endif |
418 |
|
if (sampdens != NULL) |
419 |
|
free(sampdens); |
420 |
|
pctdone = 100.0; |
421 |
+ |
if (ralrm > 0) |
422 |
+ |
report(); |
423 |
|
return; |
424 |
|
writerr: |
425 |
|
error(SYSTEM, "write error in render"); |
429 |
|
|
430 |
|
|
431 |
|
fillscanline(scanline, zline, sd, xres, y, xstep) /* fill scan at y */ |
432 |
< |
register COLOR *scanline; |
433 |
< |
register float *zline; |
432 |
> |
register COLOR *scanline; |
433 |
> |
register float *zline; |
434 |
|
register char *sd; |
435 |
|
int xres, y, xstep; |
436 |
|
{ |
437 |
|
static int nc = 0; /* number of calls */ |
438 |
|
int bl = xstep, b = xstep; |
439 |
< |
double z; |
439 |
> |
double z; |
440 |
|
register int i; |
441 |
|
|
442 |
|
z = pixvalue(scanline[0], 0, y); |
464 |
|
|
465 |
|
|
466 |
|
fillscanbar(scanbar, zbar, xres, y, ysize) /* fill interior */ |
467 |
< |
register COLOR *scanbar[]; |
468 |
< |
register float *zbar[]; |
467 |
> |
register COLOR *scanbar[]; |
468 |
> |
register float *zbar[]; |
469 |
|
int xres, y, ysize; |
470 |
|
{ |
471 |
|
COLOR vline[MAXDIV+1]; |
495 |
|
|
496 |
|
|
497 |
|
int |
498 |
< |
fillsample(colline, zline, x, y, xlen, ylen, b) /* fill interior points */ |
499 |
< |
register COLOR *colline; |
500 |
< |
register float *zline; |
498 |
> |
fillsample(colline, zline, x, y, xlen, ylen, b) /* fill interior points */ |
499 |
> |
register COLOR *colline; |
500 |
> |
register float *zline; |
501 |
|
int x, y; |
502 |
|
int xlen, ylen; |
503 |
|
int b; |
504 |
|
{ |
505 |
< |
extern double fabs(); |
506 |
< |
double ratio; |
500 |
< |
double z; |
505 |
> |
double ratio; |
506 |
> |
double z; |
507 |
|
COLOR ctmp; |
508 |
|
int ncut; |
509 |
|
register int len; |