13 |
|
#include "platform.h" |
14 |
|
#include "rtprocess.h" /* getpid() */ |
15 |
|
#include "ray.h" |
16 |
+ |
#include "func.h" |
17 |
|
#include "source.h" |
18 |
|
#include "ambient.h" |
19 |
|
#include "random.h" |
31 |
|
char *progname; /* argv[0] */ |
32 |
|
char *octname; /* octree name */ |
33 |
|
char *sigerr[NSIG]; /* signal error messages */ |
33 |
– |
char *shm_boundary = NULL; /* boundary of shared memory */ |
34 |
|
char *errfile = NULL; /* error output file */ |
35 |
|
|
36 |
|
extern time_t time(); |
52 |
|
|
53 |
|
extern double dblur; /* depth-of-field blur parameter */ |
54 |
|
|
55 |
+ |
RGBPRIMP out_prims = stdprims; /* output color primitives */ |
56 |
+ |
static RGBPRIMS our_prims; /* private output color primitives */ |
57 |
+ |
|
58 |
|
static void onsig(int signo); |
59 |
|
static void sigdie(int signo, char *msg); |
60 |
|
static void printdefaults(void); |
61 |
|
/* rpict additional features */ |
62 |
|
#ifdef PERSIST |
63 |
|
#define RPICT_FEATURES "Persist\nParallelPersist\n" \ |
64 |
+ |
"ParticipatingMedia=Mist\n" \ |
65 |
|
"Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \ |
66 |
|
"HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \ |
67 |
|
"PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \ |
68 |
|
"SmallSourceDrawing\nViewSequence\nProgressReporting\n" \ |
69 |
< |
"AdaptiveShadowTesting\nOutputs=v,l\n" |
69 |
> |
"AdaptiveShadowTesting\nOutputs=v,l\n" \ |
70 |
> |
"OutputCS=RGB,XYZ,prims\n" |
71 |
|
#else |
72 |
|
#define RPICT_FEATURES "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \ |
73 |
+ |
"ParticipatingMedia=Mist\n" \ |
74 |
|
"HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \ |
75 |
|
"PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \ |
76 |
|
"SmallSourceDrawing\nViewSequence\nProgressReporting\n" \ |
77 |
< |
"AdaptiveShadowTesting\nOutputs=v,l\n" |
77 |
> |
"AdaptiveShadowTesting\nOutputs=v,l\n" \ |
78 |
> |
"OutputCS=RGB,XYZ,prims\n" |
79 |
|
#endif |
80 |
|
|
81 |
|
|
110 |
|
strcat(RFeatureList, RPICT_FEATURES); |
111 |
|
if (argc > 1 && !strcmp(argv[1], "-features")) |
112 |
|
return feature_status(argc-2, argv+2); |
113 |
+ |
/* initialize calcomp routines */ |
114 |
+ |
initfunc(); |
115 |
|
/* option city */ |
116 |
|
for (i = 1; i < argc; i++) { |
117 |
|
/* expand arguments */ |
187 |
|
check(3,"f"); |
188 |
|
dblur = atof(argv[++i]); |
189 |
|
break; |
190 |
+ |
case 'R': /* standard RGB output */ |
191 |
+ |
if (strcmp(argv[i]+2, "RGB")) |
192 |
+ |
goto badopt; |
193 |
+ |
out_prims = stdprims; |
194 |
+ |
break; |
195 |
+ |
case 'X': /* XYZ output */ |
196 |
+ |
if (strcmp(argv[i]+2, "XYZ")) |
197 |
+ |
goto badopt; |
198 |
+ |
out_prims = xyzprims; |
199 |
+ |
break; |
200 |
+ |
case 'c': { /* chromaticities */ |
201 |
+ |
int j; |
202 |
+ |
check(3,"ffffffff"); |
203 |
+ |
rval = 0; |
204 |
+ |
for (j = 0; j < 8; j++) { |
205 |
+ |
our_prims[0][j] = atof(argv[++i]); |
206 |
+ |
rval |= fabs(our_prims[0][j]-stdprims[0][j]) > .001; |
207 |
+ |
} |
208 |
+ |
if (rval) { |
209 |
+ |
if (!colorprimsOK(our_prims)) |
210 |
+ |
error(USER, "illegal primary chromaticities"); |
211 |
+ |
out_prims = our_prims; |
212 |
+ |
} else |
213 |
+ |
out_prims = stdprims; |
214 |
+ |
} break; |
215 |
|
default: |
216 |
|
goto badopt; |
217 |
|
} |
244 |
|
check(2,"s"); |
245 |
|
recover = argv[++i]; |
246 |
|
break; |
213 |
– |
case 't': /* timer */ |
214 |
– |
check(2,"i"); |
215 |
– |
ralrm = atoi(argv[++i]); |
216 |
– |
break; |
247 |
|
#ifdef PERSIST |
248 |
|
case 'P': /* persist file */ |
249 |
|
if (argv[i][2] == 'P') { |
256 |
|
persistfile(argv[++i]); |
257 |
|
break; |
258 |
|
#endif |
259 |
+ |
case 't': /* timer */ |
260 |
+ |
check(2,"i"); |
261 |
+ |
ralrm = atoi(argv[++i]); |
262 |
+ |
break; |
263 |
|
case 'w': /* warnings */ |
264 |
|
rval = erract[WARNING].pf != NULL; |
265 |
|
check_bool(2,rval); |
274 |
|
goto badopt; |
275 |
|
} |
276 |
|
} |
277 |
+ |
/* set/check spectral sampling */ |
278 |
+ |
if (setspectrsamp(CNDX, WLPART) <= 0) |
279 |
+ |
error(USER, "unsupported spectral sampling"); |
280 |
+ |
|
281 |
|
err = setview(&ourview); /* set viewing parameters */ |
282 |
|
if (err != NULL) |
283 |
|
error(USER, err); |
357 |
|
ray_init_pmap(); /* PMAP: set up & load photon maps */ |
358 |
|
|
359 |
|
marksources(); /* find and mark sources */ |
322 |
– |
|
360 |
|
setambient(); /* initialize ambient calculation */ |
361 |
|
|
362 |
|
fflush(stdout); /* in case we're duplicating header */ |
368 |
|
close(duped1); |
369 |
|
} |
370 |
|
if (persist == PARALLEL) { /* multiprocessing */ |
371 |
< |
preload_objs(); /* preload scene */ |
335 |
< |
shm_boundary = (char *)malloc(16); |
336 |
< |
strcpy(shm_boundary, "SHM_BOUNDARY"); |
371 |
> |
cow_memshare(); /* preloads scene */ |
372 |
|
while ((rval=fork()) == 0) { /* keep on forkin' */ |
373 |
|
pflock(1); |
374 |
|
pfhold(); |
430 |
|
|
431 |
|
void |
432 |
|
wputs( /* warning output function */ |
433 |
< |
char *s |
433 |
> |
const char *s |
434 |
|
) |
435 |
|
{ |
436 |
|
int lasterrno = errno; |
437 |
+ |
if (erract[WARNING].pf == NULL) |
438 |
+ |
return; /* called by calcomp or someone */ |
439 |
|
eputs(s); |
440 |
|
errno = lasterrno; |
441 |
|
} |
443 |
|
|
444 |
|
void |
445 |
|
eputs( /* put string to stderr */ |
446 |
< |
char *s |
446 |
> |
const char *s |
447 |
|
) |
448 |
|
{ |
449 |
|
static int midline = 0; |
520 |
|
printf("-vl %f\t\t\t# view lift\n", ourview.voff); |
521 |
|
printf("-x %-9d\t\t\t# x resolution\n", hresolu); |
522 |
|
printf("-y %-9d\t\t\t# y resolution\n", vresolu); |
523 |
+ |
if (out_prims == stdprims) |
524 |
+ |
printf("-pRGB\t\t\t\t# standard RGB color output\n"); |
525 |
+ |
else if (out_prims == xyzprims) |
526 |
+ |
printf("-pXYZ\t\t\t\t# CIE XYZ color output\n"); |
527 |
+ |
else if (out_prims != NULL) |
528 |
+ |
printf("-pc %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\t# output color primaries and white point\n", |
529 |
+ |
out_prims[RED][0], out_prims[RED][1], |
530 |
+ |
out_prims[GRN][0], out_prims[GRN][1], |
531 |
+ |
out_prims[BLU][0], out_prims[BLU][1], |
532 |
+ |
out_prims[WHT][0], out_prims[WHT][1]); |
533 |
|
printf("-pa %f\t\t\t# pixel aspect ratio\n", pixaspect); |
534 |
|
printf("-pj %f\t\t\t# pixel jitter\n", dstrpix); |
535 |
|
printf("-pm %f\t\t\t# pixel motion\n", mblur); |