--- ray/src/rt/rpmain.c 2004/03/30 16:13:01 2.8 +++ ray/src/rt/rpmain.c 2024/01/17 01:31:08 2.30 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rpmain.c,v 2.8 2004/03/30 16:13:01 schorsch Exp $"; +static const char RCSid[] = "$Id: rpmain.c,v 2.30 2024/01/17 01:31:08 greg Exp $"; #endif /* * rpmain.c - main for rpict batch rendering program @@ -7,7 +7,7 @@ static const char RCSid[] = "$Id: rpmain.c,v 2.8 2004/ #include "copyright.h" -#include +#include #include #include "platform.h" @@ -18,6 +18,7 @@ static const char RCSid[] = "$Id: rpmain.c,v 2.8 2004/ #include "random.h" #include "paths.h" #include "view.h" +#include "pmapray.h" /* persistent processes define */ #ifdef F_SETLKW @@ -49,9 +50,31 @@ extern double dstrpix; /* square pixel distribution 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" \ + "ParticipatingMedia=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" \ + "ParticipatingMedia=Mist\n" \ + "HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \ + "PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \ + "SmallSourceDrawing\nViewSequence\nProgressReporting\n" \ + "AdaptiveShadowTesting\nOutputs=v,l\n" +#endif int @@ -60,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; \ @@ -74,13 +97,17 @@ main(int argc, char *argv[]) int loadflags = ~IO_FILES; int seqstart = 0; int persist = 0; - int duped1; + int duped1 = -1; int rval; int i; /* record start time */ 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 */ @@ -152,6 +179,35 @@ main(int argc, char *argv[]) check(3,"f"); mblur = atof(argv[++i]); break; + case 'd': /* aperture */ + 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; } @@ -202,7 +258,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; @@ -214,13 +270,24 @@ main(int argc, char *argv[]) goto badopt; } } + /* set/check spectral sampling */ + rval = setspectrsamp(CNDX, WLPART); + if (rval < 0) + error(USER, "unsupported spectral sampling"); + err = setview(&ourview); /* set viewing parameters */ if (err != NULL) error(USER, err); /* initialize object types */ initotypes(); /* initialize urand */ - initurand(2048); + if (rand_samp) { + srandom((long)time(0)); + initurand(0); + } else { + srandom(0L); + initurand(2048); + } /* set up signal handling */ sigdie(SIGINT, "Interrupt"); #ifdef SIGHUP @@ -273,11 +340,9 @@ main(int argc, char *argv[]) #endif if (outfile != NULL) openheader(); -#ifdef _WIN32 SET_FILE_BINARY(stdout); if (octname == NULL) SET_FILE_BINARY(stdin); -#endif readoct(octname, loadflags, &thescene, NULL); nsceneobjs = nobjects; @@ -285,14 +350,17 @@ main(int argc, char *argv[]) printargs(i, argv, stdout); printf("SOFTWARE= %s\n", VersionID); } + + ray_init_pmap(); /* PMAP: set up & load photon maps */ marksources(); /* find and mark sources */ 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); @@ -305,10 +373,11 @@ main(int argc, char *argv[]) pflock(1); pfhold(); tstart = time((time_t *)NULL); + ambsync(); /* load new values */ } if (rval < 0) error(SYSTEM, "cannot fork child for persist function"); - pfdetach(); /* parent exits */ + pfdetach(); /* parent will run then exit */ } } runagain: @@ -343,6 +412,10 @@ runagain: goto runagain; } #endif + + + ray_done_pmap(); /* PMAP: free photon maps */ + quit(0); badopt: @@ -351,13 +424,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; @@ -368,7 +441,7 @@ wputs( /* warning output function */ void eputs( /* put string to stderr */ - register char *s + const char *s ) { static int midline = 0; @@ -429,6 +502,7 @@ printdefaults(void) /* print default values to stdou ourview.type==VT_HEM ? "hemispherical" : ourview.type==VT_ANG ? "angular" : ourview.type==VT_CYL ? "cylindrical" : + ourview.type==VT_PLS ? "planisphere" : "unknown"); printf("-vp %f %f %f\t# view point\n", ourview.vp[0], ourview.vp[1], ourview.vp[2]); @@ -444,9 +518,20 @@ 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 (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); + printf("-pd %f\t\t\t# pixel depth-of-field\n", dblur); printf("-ps %-9d\t\t\t# pixel sample\n", psample); printf("-pt %f\t\t\t# pixel threshold\n", maxdiff); printf("-t %-9d\t\t\t# time between reports\n", ralrm);