ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/rpmain.c
(Generate patch)

Comparing ray/src/rt/rpmain.c (file contents):
Revision 2.10 by greg, Wed Jun 15 15:36:52 2005 UTC vs.
Revision 2.35 by greg, Wed Oct 30 16:47:03 2024 UTC

# Line 18 | Line 18 | static const char      RCSid[] = "$Id$";
18   #include  "random.h"
19   #include  "paths.h"
20   #include  "view.h"
21 + #include  "pmapray.h"
22  
23                                          /* persistent processes define */
24   #ifdef  F_SETLKW
# Line 29 | Line 30 | static const char      RCSid[] = "$Id$";
30   char  *progname;                        /* argv[0] */
31   char  *octname;                         /* octree name */
32   char  *sigerr[NSIG];                    /* signal error messages */
32 char  *shm_boundary = NULL;             /* boundary of shared memory */
33   char  *errfile = NULL;                  /* error output file */
34  
35   extern time_t  time();
# Line 51 | Line 51 | extern double  mblur;                  /* motion blur parameter */
51  
52   extern double  dblur;                   /* depth-of-field blur parameter */
53  
54 + RGBPRIMP  out_prims = stdprims;         /* output color primitives */
55 + static RGBPRIMS  our_prims;             /* private output color primitives */
56 +
57   static void onsig(int signo);
58   static void sigdie(int  signo, char  *msg);
59   static void printdefaults(void);
60 +                                        /* rpict additional features */
61 + #ifdef PERSIST
62 + #define RPICT_FEATURES  "Persist\nParallelPersist\n" \
63 +                "ParticipatingMedia=Mist\n" \
64 +                "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \
65 +                "HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \
66 +                "PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \
67 +                "SmallSourceDrawing\nViewSequence\nProgressReporting\n" \
68 +                "AdaptiveShadowTesting\nOutputs=v,l\n" \
69 +                "OutputCS=RGB,XYZ,prims\n"
70 + #else
71 + #define RPICT_FEATURES  "Recovery\nIrradianceCalc\nViewTypes=v,l,a,h,s,c\n" \
72 +                "ParticipatingMedia=Mist\n" \
73 +                "HessianAmbientCache\nAmbientAveraging\nAmbientValueSharing\n" \
74 +                "PixelJitter\nPixelSampling\nPixelMotion\nPixelDepthOfField\n" \
75 +                "SmallSourceDrawing\nViewSequence\nProgressReporting\n" \
76 +                "AdaptiveShadowTesting\nOutputs=v,l\n" \
77 +                "OutputCS=RGB,XYZ,prims\n"
78 + #endif
79  
80  
81   int
# Line 62 | Line 84 | main(int  argc, char  *argv[])
84   #define  check(ol,al)           if (argv[i][ol] || \
85                                  badarg(argc-i-1,argv+i+1,al)) \
86                                  goto badopt
87 < #define  bool(olen,var)         switch (argv[i][olen]) { \
87 > #define  check_bool(olen,var)           switch (argv[i][olen]) { \
88                                  case '\0': var = !var; break; \
89                                  case 'y': case 'Y': case 't': case 'T': \
90                                  case '+': case '1': var = 1; break; \
# Line 76 | Line 98 | main(int  argc, char  *argv[])
98          int  loadflags = ~IO_FILES;
99          int  seqstart = 0;
100          int  persist = 0;
101 <        int  duped1;
101 >        int  duped1 = -1;
102          int  rval;
103          int  i;
104                                          /* record start time */
105          tstart = time((time_t *)NULL);
106                                          /* global program name */
107          progname = argv[0] = fixargv0(argv[0]);
108 +                                        /* feature check only? */
109 +        strcat(RFeatureList, RPICT_FEATURES);
110 +        if (argc > 1 && !strcmp(argv[1], "-features"))
111 +                return feature_status(argc-2, argv+2);
112                                          /* option city */
113          for (i = 1; i < argc; i++) {
114                                                  /* expand arguments */
# Line 158 | Line 184 | main(int  argc, char  *argv[])
184                                  check(3,"f");
185                                  dblur = atof(argv[++i]);
186                                  break;
187 +                        case 'R':                               /* standard RGB output */
188 +                                if (strcmp(argv[i]+2, "RGB"))
189 +                                        goto badopt;
190 +                                out_prims = stdprims;
191 +                                break;
192 +                        case 'X':                               /* XYZ output */
193 +                                if (strcmp(argv[i]+2, "XYZ"))
194 +                                        goto badopt;
195 +                                out_prims = xyzprims;
196 +                                break;
197 +                        case 'c': {                             /* chromaticities */
198 +                                int     j;
199 +                                check(3,"ffffffff");
200 +                                rval = 0;
201 +                                for (j = 0; j < 8; j++) {
202 +                                        our_prims[0][j] = atof(argv[++i]);
203 +                                        rval |= fabs(our_prims[0][j]-stdprims[0][j]) > .001;
204 +                                }
205 +                                if (rval) {
206 +                                        if (!colorprimsOK(our_prims))
207 +                                                error(USER, "illegal primary chromaticities");
208 +                                        out_prims = our_prims;
209 +                                } else
210 +                                        out_prims = stdprims;
211 +                                } break;
212                          default:
213                                  goto badopt;
214                          }
# Line 208 | Line 259 | main(int  argc, char  *argv[])
259   #endif
260                  case 'w':                               /* warnings */
261                          rval = erract[WARNING].pf != NULL;
262 <                        bool(2,rval);
262 >                        check_bool(2,rval);
263                          if (rval) erract[WARNING].pf = wputs;
264                          else erract[WARNING].pf = NULL;
265                          break;
# Line 220 | Line 271 | main(int  argc, char  *argv[])
271                          goto badopt;
272                  }
273          }
274 +                                        /* set/check spectral sampling */
275 +        if (setspectrsamp(CNDX, WLPART) <= 0)
276 +                error(USER, "unsupported spectral sampling");
277 +
278          err = setview(&ourview);        /* set viewing parameters */
279          if (err != NULL)
280                  error(USER, err);
281                                          /* initialize object types */
282          initotypes();
283                                          /* initialize urand */
284 <        initurand(2048);
285 <        srandom(rand_samp ? (long)time(0) : 0L);
284 >        if (rand_samp) {
285 >                srandom((long)time(0));
286 >                initurand(0);
287 >        } else {
288 >                srandom(0L);
289 >                initurand(2048);
290 >        }
291                                          /* set up signal handling */
292          sigdie(SIGINT, "Interrupt");
293   #ifdef SIGHUP
# Line 280 | Line 340 | main(int  argc, char  *argv[])
340   #endif
341          if (outfile != NULL)
342                  openheader();
283 #ifdef  _WIN32
343          SET_FILE_BINARY(stdout);
344          if (octname == NULL)
345                  SET_FILE_BINARY(stdin);
287 #endif
346          readoct(octname, loadflags, &thescene, NULL);
347          nsceneobjs = nobjects;
348  
# Line 292 | Line 350 | main(int  argc, char  *argv[])
350                  printargs(i, argv, stdout);
351                  printf("SOFTWARE= %s\n", VersionID);
352          }
353 +                  
354 +        ray_init_pmap();     /* PMAP: set up & load photon maps */
355  
356          marksources();                  /* find and mark sources */
357  
358          setambient();                   /* initialize ambient calculation */
359 +        
360 +        fflush(stdout);                 /* in case we're duplicating header */
361  
362   #ifdef  PERSIST
363          if (persist) {
302                fflush(stdout);
364                  if (outfile == NULL) {          /* reconnect stdout */
365                          dup2(duped1, fileno(stdout));
366                          close(duped1);
367                  }
368                  if (persist == PARALLEL) {      /* multiprocessing */
369 <                        preload_objs();         /* preload scene */
309 <                        shm_boundary = (char *)malloc(16);
310 <                        strcpy(shm_boundary, "SHM_BOUNDARY");
369 >                        cow_memshare();         /* preloads scene */
370                          while ((rval=fork()) == 0) {    /* keep on forkin' */
371                                  pflock(1);
372                                  pfhold();
373                                  tstart = time((time_t *)NULL);
374 +                                ambsync();              /* load new values */
375                          }
376                          if (rval < 0)
377                                  error(SYSTEM, "cannot fork child for persist function");
378 <                        pfdetach();             /* parent exits */
378 >                        pfdetach();             /* parent will run then exit */
379                  }
380          }
381   runagain:
# Line 350 | Line 410 | runagain:
410                  goto runagain;
411          }
412   #endif
413 +
414 +
415 +        ray_done_pmap();           /* PMAP: free photon maps */
416 +        
417          quit(0);
418  
419   badopt:
# Line 358 | Line 422 | badopt:
422          return 1; /* pro forma return */
423  
424   #undef  check
425 < #undef  bool
425 > #undef  check_bool
426   }
427  
428  
429   void
430   wputs(                          /* warning output function */
431 <        char    *s
431 >        const char      *s
432   )
433   {
434          int  lasterrno = errno;
435 +        if (erract[WARNING].pf == NULL)
436 +                return;         /* called by calcomp or someone */
437          eputs(s);
438          errno = lasterrno;
439   }
# Line 375 | Line 441 | wputs(                         /* warning output function */
441  
442   void
443   eputs(                          /* put string to stderr */
444 <        register char  *s
444 >        const char  *s
445   )
446   {
447          static int  midline = 0;
# Line 436 | Line 502 | printdefaults(void)                    /* print default values to stdou
502                          ourview.type==VT_HEM ? "hemispherical" :
503                          ourview.type==VT_ANG ? "angular" :
504                          ourview.type==VT_CYL ? "cylindrical" :
505 +                        ourview.type==VT_PLS ? "planisphere" :
506                          "unknown");
507          printf("-vp %f %f %f\t# view point\n",
508                          ourview.vp[0], ourview.vp[1], ourview.vp[2]);
# Line 451 | Line 518 | printdefaults(void)                    /* print default values to stdou
518          printf("-vl %f\t\t\t# view lift\n", ourview.voff);
519          printf("-x  %-9d\t\t\t# x resolution\n", hresolu);
520          printf("-y  %-9d\t\t\t# y resolution\n", vresolu);
521 +        if (out_prims == stdprims)
522 +                printf("-pRGB\t\t\t\t# standard RGB color output\n");
523 +        else if (out_prims == xyzprims)
524 +                printf("-pXYZ\t\t\t\t# CIE XYZ color output\n");
525 +        else if (out_prims != NULL)
526 +                printf("-pc %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\t# output color primaries and white point\n",
527 +                                out_prims[RED][0], out_prims[RED][1],
528 +                                out_prims[GRN][0], out_prims[GRN][1],
529 +                                out_prims[BLU][0], out_prims[BLU][1],
530 +                                out_prims[WHT][0], out_prims[WHT][1]);
531          printf("-pa %f\t\t\t# pixel aspect ratio\n", pixaspect);
532          printf("-pj %f\t\t\t# pixel jitter\n", dstrpix);
533          printf("-pm %f\t\t\t# pixel motion\n", mblur);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines