--- ray/src/rt/rpmain.c 2004/03/30 16:13:01 2.8 +++ ray/src/rt/rpmain.c 2023/08/15 01:19:37 2.27 @@ -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.27 2023/08/15 01:19:37 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,28 @@ extern double dstrpix; /* square pixel distribution extern double mblur; /* motion blur parameter */ +extern double dblur; /* depth-of-field blur parameter */ + 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 +80,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 +94,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 +176,10 @@ main(int argc, char *argv[]) check(3,"f"); mblur = atof(argv[++i]); break; + case 'd': /* aperture */ + check(3,"f"); + dblur = atof(argv[++i]); + break; default: goto badopt; } @@ -202,7 +230,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; @@ -220,7 +248,13 @@ main(int argc, char *argv[]) /* 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 +307,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 +317,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 +340,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 +379,10 @@ runagain: goto runagain; } #endif + + + ray_done_pmap(); /* PMAP: free photon maps */ + quit(0); badopt: @@ -351,13 +391,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 +408,7 @@ wputs( /* warning output function */ void eputs( /* put string to stderr */ - register char *s + const char *s ) { static int midline = 0; @@ -429,6 +469,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]); @@ -447,6 +488,7 @@ printdefaults(void) /* print default values to stdou 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);