30 |
|
char *progname; /* argv[0] */ |
31 |
|
char *octname; /* octree name */ |
32 |
|
char *sigerr[NSIG]; /* signal error messages */ |
33 |
– |
char *shm_boundary = NULL; /* boundary of shared memory */ |
33 |
|
char *errfile = NULL; /* error output file */ |
34 |
< |
|
34 |
> |
#ifdef SSKIPOPT |
35 |
> |
int *ssndx_map = NULL; /* loaded source index map */ |
36 |
> |
float *scorr_map = NULL; /* loaded source correction map */ |
37 |
> |
#endif |
38 |
|
extern time_t time(); |
39 |
|
extern time_t tstart; /* start time */ |
40 |
|
|
63 |
|
/* rpict additional features */ |
64 |
|
#ifdef PERSIST |
65 |
|
#define RPICT_FEATURES "Persist\nParallelPersist\n" \ |
66 |
< |
"Hyperspectral\nParticipatingMedia=Mist\n" \ |
66 |
> |
"ParticipatingMedia=Mist\n" \ |
67 |
|
"Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \ |
68 |
|
"HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \ |
69 |
|
"PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \ |
70 |
|
"SmallSourceDrawing\nViewSequence\nProgressReporting\n" \ |
71 |
< |
"AdaptiveShadowTesting\nOutputs=v,l\n" |
71 |
> |
"AdaptiveShadowTesting\nOutputs=v,l\n" \ |
72 |
> |
"OutputCS=RGB,XYZ,prims\n" |
73 |
|
#else |
74 |
|
#define RPICT_FEATURES "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \ |
75 |
< |
"Hyperspectral\nParticipatingMedia=Mist\n" \ |
75 |
> |
"ParticipatingMedia=Mist\n" \ |
76 |
|
"HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \ |
77 |
|
"PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \ |
78 |
|
"SmallSourceDrawing\nViewSequence\nProgressReporting\n" \ |
79 |
< |
"AdaptiveShadowTesting\nOutputs=v,l\n" |
79 |
> |
"AdaptiveShadowTesting\nOutputs=v,l\n" \ |
80 |
> |
"OutputCS=RGB,XYZ,prims\n" |
81 |
|
#endif |
82 |
|
|
83 |
|
|
98 |
|
char *recover = NULL; |
99 |
|
char *outfile = NULL; |
100 |
|
char *zfile = NULL; |
101 |
+ |
#ifdef SSKIPOPT |
102 |
+ |
char *sskipspec = NULL; |
103 |
+ |
char *scorrfile = NULL; |
104 |
+ |
#endif |
105 |
|
int loadflags = ~IO_FILES; |
106 |
|
int seqstart = 0; |
107 |
|
int persist = 0; |
248 |
|
check(2,"s"); |
249 |
|
recover = argv[++i]; |
250 |
|
break; |
251 |
< |
case 't': /* timer */ |
252 |
< |
check(2,"i"); |
245 |
< |
ralrm = atoi(argv[++i]); |
246 |
< |
break; |
247 |
< |
#if MAXCSAMP>3 |
248 |
< |
case 'c': /* spectral sampling */ |
251 |
> |
#ifdef SSKIPOPT |
252 |
> |
case 'd': |
253 |
|
switch (argv[i][2]) { |
254 |
< |
case 's': /* spectral bin count */ |
255 |
< |
check(3,"i"); |
256 |
< |
NCSAMP = atoi(argv[++i]); |
254 |
> |
case 'S': /* direct skip */ |
255 |
> |
check(3,"s"); |
256 |
> |
sskipspec = argv[++i]; |
257 |
|
break; |
258 |
< |
case 'w': /* wavelength extrema */ |
259 |
< |
check(3,"ff"); |
260 |
< |
WLPART[0] = atof(argv[++i]); |
257 |
< |
WLPART[3] = atof(argv[++i]); |
258 |
> |
case 'C': /* direct correction */ |
259 |
> |
check(3,"s"); |
260 |
> |
scorrfile = argv[++i]; |
261 |
|
break; |
259 |
– |
#if 0 |
260 |
– |
case 'o': /* output spectral results */ |
261 |
– |
rval = (out_prims == NULL); |
262 |
– |
check_bool(3,rval); |
263 |
– |
if (rval) out_prims = NULL; |
264 |
– |
else if (out_prims == NULL) out_prims = stdprims; |
265 |
– |
break; |
266 |
– |
#endif |
262 |
|
default: |
263 |
|
goto badopt; |
264 |
|
} |
276 |
|
persistfile(argv[++i]); |
277 |
|
break; |
278 |
|
#endif |
279 |
+ |
case 't': /* timer */ |
280 |
+ |
check(2,"i"); |
281 |
+ |
ralrm = atoi(argv[++i]); |
282 |
+ |
break; |
283 |
|
case 'w': /* warnings */ |
284 |
|
rval = erract[WARNING].pf != NULL; |
285 |
|
check_bool(2,rval); |
294 |
|
goto badopt; |
295 |
|
} |
296 |
|
} |
297 |
+ |
/* set/check spectral sampling */ |
298 |
+ |
if (setspectrsamp(CNDX, WLPART) <= 0) |
299 |
+ |
error(USER, "unsupported spectral sampling"); |
300 |
+ |
|
301 |
|
err = setview(&ourview); /* set viewing parameters */ |
302 |
|
if (err != NULL) |
303 |
|
error(USER, err); |
377 |
|
ray_init_pmap(); /* PMAP: set up & load photon maps */ |
378 |
|
|
379 |
|
marksources(); /* find and mark sources */ |
380 |
< |
|
380 |
> |
#ifdef SSKIPOPT |
381 |
> |
if (sskipspec != NULL) { /* load source skip maps? */ |
382 |
> |
if ((seqstart > 0) | (persist > 0)) |
383 |
> |
error(USER, |
384 |
> |
"source skip map incompatible with -S/-P/-PP"); |
385 |
> |
if (srcskip_open(sskipspec, scorrfile) <= 0) |
386 |
> |
quit(1); |
387 |
> |
if ((ssndx_map = srcskip_ndxmap()) == NULL) |
388 |
> |
quit(1); |
389 |
> |
if (scorrfile != NULL && |
390 |
> |
(scorr_map = srcskip_corrmap()) == NULL) |
391 |
> |
quit(1); |
392 |
> |
srcskip_close(); /* leaves maps loaded */ |
393 |
> |
} |
394 |
> |
#endif |
395 |
|
setambient(); /* initialize ambient calculation */ |
396 |
|
|
397 |
|
fflush(stdout); /* in case we're duplicating header */ |
403 |
|
close(duped1); |
404 |
|
} |
405 |
|
if (persist == PARALLEL) { /* multiprocessing */ |
406 |
< |
preload_objs(); /* preload scene */ |
390 |
< |
shm_boundary = (char *)malloc(16); |
391 |
< |
strcpy(shm_boundary, "SHM_BOUNDARY"); |
406 |
> |
cow_memshare(); /* preloads scene */ |
407 |
|
while ((rval=fork()) == 0) { /* keep on forkin' */ |
408 |
|
pflock(1); |
409 |
|
pfhold(); |
462 |
|
#undef check_bool |
463 |
|
} |
464 |
|
|
465 |
+ |
#ifdef SSKIPOPT |
466 |
+ |
void /* source skip parameters for primary */ |
467 |
+ |
sskip_ray(RAY *r, double h, double v) |
468 |
+ |
{ |
469 |
+ |
size_t ssi; |
470 |
|
|
471 |
+ |
if (ssndx_map == NULL) |
472 |
+ |
return; /* nothing to do */ |
473 |
+ |
|
474 |
+ |
/* rows counted from the top! */ |
475 |
+ |
ssi = (size_t)((1.-v)*sskip_dim[1])*sskip_dim[0] + |
476 |
+ |
(size_t)(h*sskip_dim[0]); |
477 |
+ |
|
478 |
+ |
if (ssi >= sskip_dim[0]*sskip_dim[1]) |
479 |
+ |
error(CONSISTENCY, "bad index in sskip_ray()"); |
480 |
+ |
|
481 |
+ |
r->rsrc = ssndx_map[ssi]; |
482 |
+ |
if (scorr_map != NULL) |
483 |
+ |
r->scorr = scorr_map[ssi]; |
484 |
+ |
} |
485 |
+ |
#endif |
486 |
+ |
|
487 |
|
void |
488 |
|
wputs( /* warning output function */ |
489 |
|
const char *s |
490 |
|
) |
491 |
|
{ |
492 |
|
int lasterrno = errno; |
493 |
+ |
if (erract[WARNING].pf == NULL) |
494 |
+ |
return; /* called by calcomp or someone */ |
495 |
|
eputs(s); |
496 |
|
errno = lasterrno; |
497 |
|
} |
576 |
|
printf("-vl %f\t\t\t# view lift\n", ourview.voff); |
577 |
|
printf("-x %-9d\t\t\t# x resolution\n", hresolu); |
578 |
|
printf("-y %-9d\t\t\t# y resolution\n", vresolu); |
541 |
– |
if (NCSAMP > 3) { |
542 |
– |
printf("-cs %-2d\t\t\t\t# number of spectral bins\n", NCSAMP); |
543 |
– |
printf("-cw %3.0f %3.0f\t\t\t# wavelength limits (nm)\n", |
544 |
– |
WLPART[3], WLPART[0]); |
545 |
– |
/* printf(out_prims != NULL ? "-co-\t\t\t\t# output tristimulus colors\n" : |
546 |
– |
"-co+\t\t\t\t# output spectral values\n"); |
547 |
– |
*/ } |
579 |
|
if (out_prims == stdprims) |
580 |
|
printf("-pRGB\t\t\t\t# standard RGB color output\n"); |
581 |
|
else if (out_prims == xyzprims) |