--- ray/src/rt/rpmain.c 2016/03/06 01:13:18 2.17 +++ ray/src/rt/rpmain.c 2023/11/15 18:02:53 2.28 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rpmain.c,v 2.17 2016/03/06 01:13:18 schorsch Exp $"; +static const char RCSid[] = "$Id: rpmain.c,v 2.28 2023/11/15 18:02:53 greg Exp $"; #endif /* * rpmain.c - main for rpict batch rendering program @@ -52,9 +52,29 @@ extern double mblur; /* motion blur parameter */ extern double dblur; /* depth-of-field blur parameter */ +RGBPRIMP out_prims = stdprims; /* output color primitives */ +static RGBPRIMS our_prims; /* private output color primitives */ + static void onsig(int signo); static void sigdie(int signo, char *msg); static void printdefaults(void); + /* rpict additional features */ +#ifdef PERSIST +#define RPICT_FEATURES "Persist\nParallelPersist\n" \ + "Hyperspectral\nParticipatingMedia=Mist\n" \ + "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \ + "HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \ + "PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \ + "SmallSourceDrawing\nViewSequence\nProgressReporting\n" \ + "AdaptiveShadowTesting\nOutputs=v,l\n" +#else +#define RPICT_FEATURES "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \ + "Hyperspectral\nParticipatingMedia=Mist\n" \ + "HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \ + "PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \ + "SmallSourceDrawing\nViewSequence\nProgressReporting\n" \ + "AdaptiveShadowTesting\nOutputs=v,l\n" +#endif int @@ -63,7 +83,7 @@ main(int argc, char *argv[]) #define check(ol,al) if (argv[i][ol] || \ badarg(argc-i-1,argv+i+1,al)) \ goto badopt -#define bool(olen,var) switch (argv[i][olen]) { \ +#define check_bool(olen,var) switch (argv[i][olen]) { \ case '\0': var = !var; break; \ case 'y': case 'Y': case 't': case 'T': \ case '+': case '1': var = 1; break; \ @@ -84,6 +104,10 @@ main(int argc, char *argv[]) tstart = time((time_t *)NULL); /* global program name */ progname = argv[0] = fixargv0(argv[0]); + /* feature check only? */ + strcat(RFeatureList, RPICT_FEATURES); + if (argc > 1 && !strcmp(argv[1], "-features")) + return feature_status(argc-2, argv+2); /* option city */ for (i = 1; i < argc; i++) { /* expand arguments */ @@ -159,6 +183,31 @@ main(int argc, char *argv[]) check(3,"f"); dblur = atof(argv[++i]); break; + case 'R': /* standard RGB output */ + if (strcmp(argv[i]+2, "RGB")) + goto badopt; + out_prims = stdprims; + break; + case 'X': /* XYZ output */ + if (strcmp(argv[i]+2, "XYZ")) + goto badopt; + out_prims = xyzprims; + break; + case 'c': { /* chromaticities */ + int j; + check(3,"ffffffff"); + rval = 0; + for (j = 0; j < 8; j++) { + our_prims[0][j] = atof(argv[++i]); + rval |= fabs(our_prims[0][j]-stdprims[0][j]) > .001; + } + if (rval) { + if (!colorprimsOK(our_prims)) + error(USER, "illegal primary chromaticities"); + out_prims = our_prims; + } else + out_prims = stdprims; + } break; default: goto badopt; } @@ -195,6 +244,31 @@ main(int argc, char *argv[]) check(2,"i"); ralrm = atoi(argv[++i]); break; +#if MAXCSAMP>3 + case 'c': /* spectral sampling */ + switch (argv[i][2]) { + case 's': /* spectral bin count */ + check(3,"i"); + NCSAMP = atoi(argv[++i]); + break; + case 'w': /* wavelength extrema */ + check(3,"ff"); + WLPART[0] = atof(argv[++i]); + WLPART[3] = atof(argv[++i]); + break; +#if 0 + case 'o': /* output spectral results */ + rval = (out_prims == NULL); + check_bool(3,rval); + if (rval) out_prims = NULL; + else if (out_prims == NULL) out_prims = stdprims; + break; +#endif + default: + goto badopt; + } + break; +#endif #ifdef PERSIST case 'P': /* persist file */ if (argv[i][2] == 'P') { @@ -209,7 +283,7 @@ main(int argc, char *argv[]) #endif case 'w': /* warnings */ rval = erract[WARNING].pf != NULL; - bool(2,rval); + check_bool(2,rval); if (rval) erract[WARNING].pf = wputs; else erract[WARNING].pf = NULL; break; @@ -286,11 +360,9 @@ main(int argc, char *argv[]) #endif if (outfile != NULL) openheader(); -#if defined(_WIN32) || defined(_WIN64) SET_FILE_BINARY(stdout); if (octname == NULL) SET_FILE_BINARY(stdin); -#endif readoct(octname, loadflags, &thescene, NULL); nsceneobjs = nobjects; @@ -305,9 +377,10 @@ main(int argc, char *argv[]) setambient(); /* initialize ambient calculation */ + fflush(stdout); /* in case we're duplicating header */ + #ifdef PERSIST if (persist) { - fflush(stdout); if (outfile == NULL) { /* reconnect stdout */ dup2(duped1, fileno(stdout)); close(duped1); @@ -371,13 +444,13 @@ badopt: return 1; /* pro forma return */ #undef check -#undef bool +#undef check_bool } void wputs( /* warning output function */ - char *s + const char *s ) { int lasterrno = errno; @@ -388,7 +461,7 @@ wputs( /* warning output function */ void eputs( /* put string to stderr */ - register char *s + const char *s ) { static int midline = 0; @@ -465,6 +538,23 @@ printdefaults(void) /* print default values to stdou printf("-vl %f\t\t\t# view lift\n", ourview.voff); printf("-x %-9d\t\t\t# x resolution\n", hresolu); printf("-y %-9d\t\t\t# y resolution\n", vresolu); + if (NCSAMP > 3) { + printf("-cs %-2d\t\t\t\t# number of spectral bins\n", NCSAMP); + printf("-cw %3.0f %3.0f\t\t\t# wavelength limits (nm)\n", + WLPART[3], WLPART[0]); +/* printf(out_prims != NULL ? "-co-\t\t\t\t# output tristimulus colors\n" : + "-co+\t\t\t\t# output spectral values\n"); +*/ } + if (out_prims == stdprims) + printf("-pRGB\t\t\t\t# standard RGB color output\n"); + else if (out_prims == xyzprims) + printf("-pXYZ\t\t\t\t# CIE XYZ color output\n"); + else if (out_prims != NULL) + printf("-pc %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\t# output color primaries and white point\n", + out_prims[RED][0], out_prims[RED][1], + out_prims[GRN][0], out_prims[GRN][1], + out_prims[BLU][0], out_prims[BLU][1], + out_prims[WHT][0], out_prims[WHT][1]); printf("-pa %f\t\t\t# pixel aspect ratio\n", pixaspect); printf("-pj %f\t\t\t# pixel jitter\n", dstrpix); printf("-pm %f\t\t\t# pixel motion\n", mblur);