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

Comparing ray/src/rt/rtmain.c (file contents):
Revision 2.42 by greg, Mon Feb 6 20:34:17 2023 UTC vs.
Revision 2.61 by greg, Fri Jun 20 16:34:23 2025 UTC

# Line 13 | Line 13 | static const char      RCSid[] = "$Id$";
13   #include  "rtprocess.h" /* getpid() */
14   #include  "resolu.h"
15   #include  "ray.h"
16 + #include  "func.h"
17   #include  "source.h"
18   #include  "ambient.h"
19   #include  "random.h"
19 #include  "paths.h"
20   #include  "pmapray.h"
21
22 extern char     *progname;              /* global argv[0] */
23
24 extern char     *shm_boundary;          /* boundary of shared memory */
25
21                                          /* persistent processes define */
22   #ifdef  F_SETLKW
23   #define  PERSIST        1               /* normal persist */
# Line 35 | Line 30 | char  *errfile = NULL;                 /* error output file */
30  
31   int  nproc = 1;                         /* number of processes */
32  
38 extern char  *formstr(int f);           /* string from format */
33   extern int  setrtoutput(void);          /* set output values */
34  
35   int  inform = 'a';                      /* input format */
# Line 60 | Line 54 | extern void  tranotify(OBJECT obj);
54   char  *tralist[MAXMODLIST];             /* list of modifers to trace (or no) */
55   int  traincl = -1;                      /* include == 1, exclude == 0 */
56  
57 + double  (*sens_curve)(const SCOLOR scol) = NULL;        /* spectral conversion for 1-channel */
58 + double  out_scalefactor = 1;            /* output calibration scale factor */
59 + RGBPRIMP  out_prims = stdprims;         /* output color primitives (NULL if spectral) */
60 + static RGBPRIMS  our_prims;             /* private output color primitives */
61 +
62   static int  loadflags = ~IO_FILES;      /* what to load from octree */
63  
64   static void onsig(int  signo);
# Line 67 | Line 66 | static void sigdie(int  signo, char  *msg);
66   static void printdefaults(void);
67  
68   #ifdef PERSIST
69 < #define RTRACE_FEATURES "Persist\nParallelPersist\nMultiProcessing\n" \
69 > #define RTRACE_FEATURES "Persist\nParallelPersist\nMultiprocessing\n" \
70                          "IrradianceCalc\nImmediateIrradiance\nDistanceLimiting\n" \
71 +                        "ParticipatingMedia=Mist\n" \
72                          "HessianAmbientCache\nAmbientAveraging\n" \
73                          "AmbientValueSharing\nAdaptiveShadowTesting\n" \
74 <                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n"
74 >                        "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \
75 >                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" \
76 >                        "OutputCS=RGB,XYZ,Y,S,M,prims,spec\n"
77   #else
78   #define RTRACE_FEATURES "IrradianceCalc\nIrradianceCalc\nDistanceLimiting\n" \
79 +                        "ParticipatingMedia=Mist\n" \
80                          "HessianAmbientCache\nAmbientAveraging\n" \
81                          "AmbientValueSharing\nAdaptiveShadowTesting\n" \
82 <                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n"
82 >                        "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \
83 >                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" \
84 >                        "OutputCS=RGB,XYZ,Y,S,M,prims,spec\n"
85   #endif
86  
87  
# Line 104 | Line 109 | main(int  argc, char  *argv[])
109          progname = argv[0] = fixargv0(argv[0]);
110                                          /* feature check only? */
111          strcat(RFeatureList, RTRACE_FEATURES);
112 <        if (argc == 2 && !strcmp(argv[1], "-features"))
112 >        if (argc > 1 && !strcmp(argv[1], "-features"))
113                  return feature_status(argc-2, argv+2);
114 +                                        /* initialize calcomp routines */
115 +        initfunc();
116                                          /* add trace notify function */
117          for (i = 0; addobjnotify[i] != NULL; i++)
118                  ;
# Line 150 | Line 157 | main(int  argc, char  *argv[])
157                          check(2,"i");
158                          vresolu = atoi(argv[++i]);
159                          break;
160 <                case 'w':                               /* warnings */
160 >                case 'w':                               /* warnings & spectral */
161                          rval = erract[WARNING].pf != NULL;
162                          check_bool(2,rval);
163                          if (rval) erract[WARNING].pf = wputs;
# Line 252 | Line 259 | main(int  argc, char  *argv[])
259                                  goto badopt;
260                          }
261                          break;
262 +                case 'p':                               /* value output */
263 +                        switch (argv[i][2]) {
264 +                        case 'R':                       /* standard RGB output */
265 +                                if (strcmp(argv[i]+2, "RGB"))
266 +                                        goto badopt;
267 +                                out_prims = stdprims;
268 +                                out_scalefactor = 1;
269 +                                sens_curve = NULL;
270 +                                break;
271 +                        case 'X':                       /* XYZ output */
272 +                                if (strcmp(argv[i]+2, "XYZ"))
273 +                                        goto badopt;
274 +                                out_prims = xyzprims;
275 +                                out_scalefactor = WHTEFFICACY;
276 +                                sens_curve = NULL;
277 +                                break;
278 +                        case 'c': {
279 +                                int     j;
280 +                                check(3,"ffffffff");
281 +                                rval = 0;
282 +                                for (j = 0; j < 8; j++) {
283 +                                        our_prims[0][j] = atof(argv[++i]);
284 +                                        rval |= fabs(our_prims[0][j]-stdprims[0][j]) > .001;
285 +                                }
286 +                                if (rval) {
287 +                                        if (!colorprimsOK(our_prims))
288 +                                                error(USER, "illegal primary chromaticities");
289 +                                        out_prims = our_prims;
290 +                                } else
291 +                                        out_prims = stdprims;
292 +                                out_scalefactor = 1;
293 +                                sens_curve = NULL;
294 +                                } break;
295 +                        case 'Y':                       /* photopic response */
296 +                                if (argv[i][3])
297 +                                        goto badopt;
298 +                                sens_curve = scolor_photopic;
299 +                                out_scalefactor = WHTEFFICACY;
300 +                                break;
301 +                        case 'S':                       /* scotopic response */
302 +                                if (argv[i][3])
303 +                                        goto badopt;
304 +                                sens_curve = scolor_scotopic;
305 +                                out_scalefactor = WHTSCOTOPIC;
306 +                                break;
307 +                        case 'M':                       /* melanopic response */
308 +                                if (argv[i][3])
309 +                                        goto badopt;
310 +                                sens_curve = scolor_melanopic;
311 +                                out_scalefactor = WHTMELANOPIC;
312 +                                break;
313 +                        default:
314 +                                goto badopt;
315 +                        }
316 +                        break;
317 + #if MAXCSAMP>3
318 +                case 'c':                               /* output spectral results */
319 +                        if (argv[i][2] != 'o')
320 +                                goto badopt;
321 +                        rval = (out_prims == NULL) & (sens_curve == NULL);
322 +                        check_bool(3,rval);
323 +                        if (rval) {
324 +                                out_prims = NULL;
325 +                                sens_curve = NULL;
326 +                        } else if (out_prims == NULL)
327 +                                out_prims = stdprims;
328 +                        break;
329 + #endif
330   #ifdef  PERSIST
331                  case 'P':                               /* persist file */
332                          if (argv[i][2] == 'P') {
# Line 268 | Line 343 | main(int  argc, char  *argv[])
343                          goto badopt;
344                  }
345          }
346 +                                        /* set/check spectral sampling */
347 +        rval = setspectrsamp(CNDX, WLPART);
348 +        if (rval < 0)
349 +                error(USER, "unsupported spectral sampling");
350 +        if (sens_curve != NULL)
351 +                out_prims = NULL;
352 +        else if (out_prims != NULL) {
353 +                if (!rval)
354 +                        error(WARNING, "spectral range incompatible with color output");
355 +        } else if (NCSAMP == 3)
356 +                out_prims = stdprims;   /* 3 samples do not a spectrum make */
357          if (nproc > 1 && persist)
358                  error(USER, "multiprocessing incompatible with persist file");
359                                          /* initialize object types */
360          initotypes();
361                                          /* initialize urand */
362 <        if (rand_samp) {
277 <                srandom((long)time(0));
278 <                initurand(0);
279 <        } else {
280 <                srandom(0L);
281 <                initurand(2048);
282 <        }
362 >        reset_random();
363                                          /* set up signal handling */
364          sigdie(SIGINT, "Interrupt");
365   #ifdef SIGHUP
# Line 337 | Line 417 | main(int  argc, char  *argv[])
417                  printf("SOFTWARE= %s\n", VersionID);
418                  fputnow(stdout);
419                  if (rval > 0)           /* saved from setrtoutput() call */
420 <                        printf("NCOMP=%d\n", rval);
420 >                        fputncomp(rval, stdout);
421 >                if (NCSAMP > 3)
422 >                        fputwlsplit(WLPART, stdout);
423 >                if ((out_prims != stdprims) & (out_prims != NULL))
424 >                        fputprims(out_prims, stdout);
425                  if ((outform == 'f') | (outform == 'd'))
426                          fputendian(stdout);
427                  fputformat(formstr(outform), stdout);
428 <                putchar('\n');
428 >                fputc('\n', stdout);    /* end of header */
429          }
430  
431          if (!castonly) {        /* any actual ray traversal to do? */
# Line 362 | Line 446 | main(int  argc, char  *argv[])
446                  dup2(duped1, fileno(stdout));
447                  close(duped1);
448                  if (persist == PARALLEL) {      /* multiprocessing */
449 <                        preload_objs();         /* preload scene */
366 <                        shm_boundary = (char *)malloc(16);
367 <                        strcpy(shm_boundary, "SHM_BOUNDARY");
449 >                        cow_memshare();         /* preloads scene */
450                          while ((rval=fork()) == 0) {    /* keep on forkin' */
451                                  pflock(1);
452                                  pfhold();
# Line 417 | Line 499 | badopt:
499  
500   void
501   wputs(                          /* warning output function */
502 <        char    *s
502 >        const char      *s
503   )
504   {
505          int  lasterrno = errno;
506 +        if (erract[WARNING].pf == NULL)
507 +                return;         /* called by calcomp or someone */
508          eputs(s);
509          errno = lasterrno;
510   }
# Line 428 | Line 512 | wputs(                         /* warning output function */
512  
513   void
514   eputs(                          /* put string to stderr */
515 <        char  *s
515 >        const char  *s
516   )
517   {
518          static int  midline = 0;
# Line 485 | Line 569 | printdefaults(void)                    /* print default values to stdou
569   {
570          char  *cp;
571  
572 +        printf(erract[WARNING].pf != NULL ?
573 +                        "-w+\t\t\t\t# warning messages on\n" :
574 +                        "-w-\t\t\t\t# warning messages off\n");
575          if (imm_irrad)
576                  printf("-I+\t\t\t\t# immediate irradiance on\n");
577          printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc);
# Line 493 | Line 580 | printdefaults(void)                    /* print default values to stdou
580          printf("-y %-9d\t\t\t# y resolution\n", vresolu);
581          printf(lim_dist ? "-ld+\t\t\t\t# limit distance on\n" :
582                          "-ld-\t\t\t\t# limit distance off\n");
583 <        printf("-h%c\t\t\t\t# %s header\n", loadflags & IO_INFO ? '+' : '-',
584 <                        loadflags & IO_INFO ? "output" : "no");
583 >        printf(loadflags & IO_INFO ? "-h+\t\t\t\t# output header\n" :
584 >                        "-h-\t\t\t\t# no header\n");
585          printf("-f%c%c\t\t\t\t# format input/output = %s/%s\n",
586                          inform, outform, formstr(inform), formstr(outform));
587          printf("-o%-9s\t\t\t# output", outvals);
# Line 521 | Line 608 | printdefaults(void)                    /* print default values to stdou
608                  case 'M': printf(" material"); break;
609                  case '~': printf(" tilde"); break;
610                  }
611 <        putchar('\n');
612 <        printf(erract[WARNING].pf != NULL ?
613 <                        "-w+\t\t\t\t# warning messages on\n" :
614 <                        "-w-\t\t\t\t# warning messages off\n");
611 >        fputc('\n', stdout);
612 >        if (sens_curve == scolor_photopic)
613 >                printf("-pY\t\t\t\t# photopic output\n");
614 >        else if (sens_curve == scolor_scotopic)
615 >                printf("-pS\t\t\t\t# scotopic output\n");
616 >        else if (sens_curve == scolor_melanopic)
617 >                printf("-pM\t\t\t\t# melanopic output\n");
618 >        else if (out_prims == stdprims)
619 >                printf("-pRGB\t\t\t\t# standard RGB color output\n");
620 >        else if (out_prims == xyzprims)
621 >                printf("-pXYZ\t\t\t\t# CIE XYZ color output\n");
622 >        else if (out_prims != NULL)
623 >                printf("-pc %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\t# output color primaries and white point\n",
624 >                                out_prims[RED][0], out_prims[RED][1],
625 >                                out_prims[GRN][0], out_prims[GRN][1],
626 >                                out_prims[BLU][0], out_prims[BLU][1],
627 >                                out_prims[WHT][0], out_prims[WHT][1]);
628 >        if ((sens_curve == NULL) & (NCSAMP > 3))
629 >                printf(out_prims != NULL ? "-co-\t\t\t\t# output tristimulus colors\n" :
630 >                                "-co+\t\t\t\t# output spectral values\n");
631          print_rdefaults();
632   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines