1 |
< |
/* Copyright (c) 1993 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1995 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
20 |
|
#include <sys/resource.h> |
21 |
|
#else |
22 |
|
#include <sys/times.h> |
23 |
– |
#include <sys/utsname.h> |
23 |
|
#include <unistd.h> |
24 |
|
#endif |
25 |
|
#endif |
63 |
|
int directvis = 1; /* sources visible? */ |
64 |
|
double srcsizerat = .25; /* maximum ratio source size/dist. */ |
65 |
|
|
66 |
+ |
COLOR cextinction = BLKCOLOR; /* global extinction coefficient */ |
67 |
+ |
double salbedo = 0.; /* global scattering albedo */ |
68 |
+ |
double seccg = 0.; /* global scattering eccentricity */ |
69 |
+ |
double ssampdist = 0.; /* scatter sampling distance */ |
70 |
+ |
|
71 |
|
double specthresh = .15; /* specular sampling threshold */ |
72 |
|
double specjitter = 1.; /* specular sampling jitter */ |
73 |
|
|
74 |
+ |
int backvis = 1; /* back face visibility */ |
75 |
+ |
|
76 |
|
int maxdepth = 6; /* maximum recursion depth */ |
77 |
|
double minweight = 5e-3; /* minimum ray weight */ |
78 |
|
|
79 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
80 |
+ |
int ambvwt = 0; /* initial weight for ambient value */ |
81 |
|
double ambacc = 0.2; /* ambient accuracy */ |
82 |
|
int ambres = 32; /* ambient resolution */ |
83 |
|
int ambdiv = 128; /* ambient divisions */ |
140 |
|
#ifndef NIX |
141 |
|
report() /* report progress */ |
142 |
|
{ |
143 |
+ |
extern char *myhostname(); |
144 |
|
double u, s; |
145 |
|
#ifdef BSD |
138 |
– |
char hostname[257]; |
146 |
|
struct rusage rubuf; |
147 |
|
#else |
148 |
|
struct tms tbuf; |
142 |
– |
struct utsname nambuf; |
149 |
|
double period; |
144 |
– |
#define hostname nambuf.nodename |
150 |
|
#endif |
151 |
|
|
152 |
|
tlastrept = time((time_t *)NULL); |
157 |
|
getrusage(RUSAGE_CHILDREN, &rubuf); |
158 |
|
u += rubuf.ru_utime.tv_sec + rubuf.ru_utime.tv_usec/1e6; |
159 |
|
s += rubuf.ru_stime.tv_sec + rubuf.ru_stime.tv_usec/1e6; |
155 |
– |
gethostname(hostname, sizeof(hostname)); |
160 |
|
#else |
161 |
|
times(&tbuf); |
162 |
|
#ifdef _SC_CLK_TCK |
166 |
|
#endif |
167 |
|
u = ( tbuf.tms_utime + tbuf.tms_cutime ) * period; |
168 |
|
s = ( tbuf.tms_stime + tbuf.tms_cstime ) * period; |
165 |
– |
uname(&nambuf); |
169 |
|
#endif |
170 |
|
|
171 |
|
sprintf(errmsg, |
172 |
|
"%lu rays, %4.2f%% after %.3fu %.3fs %.3fr hours on %s\n", |
173 |
|
nrays, pctdone, u/3600., s/3600., |
174 |
< |
(tlastrept-tstart)/3600., hostname); |
174 |
> |
(tlastrept-tstart)/3600., myhostname()); |
175 |
|
eputs(errmsg); |
176 |
|
#ifndef BSD |
177 |
|
signal(SIGCONT, report); |
175 |
– |
#undef hostname |
178 |
|
#endif |
179 |
|
} |
180 |
|
#else |
393 |
|
fprtresolu(hres, vres, stdout); |
394 |
|
/* recover file and compute first */ |
395 |
|
i = salvage(oldfile); |
396 |
+ |
if (i >= vres) |
397 |
+ |
goto alldone; |
398 |
|
if (zfd != -1 && i > 0 && |
399 |
|
lseek(zfd, (long)i*hres*sizeof(float), 0) == -1) |
400 |
|
error(SYSTEM, "z-file seek error in render"); |
450 |
|
} |
451 |
|
/* clean up */ |
452 |
|
signal(SIGCONT, SIG_IGN); |
453 |
< |
if (zfd != -1) { |
450 |
< |
if (write(zfd, (char *)zbar[0], hres*sizeof(float)) |
453 |
> |
if (zfd != -1 && write(zfd, (char *)zbar[0], hres*sizeof(float)) |
454 |
|
< hres*sizeof(float)) |
455 |
< |
goto writerr; |
455 |
> |
goto writerr; |
456 |
> |
fwritescan(scanbar[0], hres, stdout); |
457 |
> |
if (fflush(stdout) == EOF) |
458 |
> |
goto writerr; |
459 |
> |
alldone: |
460 |
> |
if (zfd != -1) { |
461 |
|
if (close(zfd) == -1) |
462 |
|
goto writerr; |
463 |
|
for (i = 0; i <= psample; i++) |
464 |
|
free((char *)zbar[i]); |
465 |
|
} |
458 |
– |
fwritescan(scanbar[0], hres, stdout); |
459 |
– |
if (fflush(stdout) == EOF) |
460 |
– |
goto writerr; |
466 |
|
for (i = 0; i <= psample; i++) |
467 |
|
free((char *)scanbar[i]); |
468 |
|
if (sampdens != NULL) |
607 |
|
{ |
608 |
|
static RAY thisray; |
609 |
|
|
610 |
< |
if (viewray(thisray.rorg, thisray.rdir, &ourview, |
611 |
< |
(x+pixjitter())/hres, (y+pixjitter())/vres) < 0) { |
610 |
> |
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview, |
611 |
> |
(x+pixjitter())/hres, (y+pixjitter())/vres)) < -FTINY) { |
612 |
|
setcolor(col, 0.0, 0.0, 0.0); |
613 |
|
return(0.0); |
614 |
|
} |