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.32 by greg, Mon Apr 6 04:10:44 2020 UTC vs.
Revision 2.53 by greg, Tue Apr 30 22:25:46 2024 UTC

# Line 35 | Line 35 | char  *errfile = NULL;                 /* error output file */
35  
36   int  nproc = 1;                         /* number of processes */
37  
38 extern char  *formstr(int f);           /* string from format */
38   extern int  setrtoutput(void);          /* set output values */
39  
40   int  inform = 'a';                      /* input format */
# Line 45 | Line 44 | char  *outvals = "v";                  /* output specification */
44   int  hresolu = 0;                       /* horizontal (scan) size */
45   int  vresolu = 0;                       /* vertical resolution */
46  
47 < int  castonly = 0;                      /* only doing ray-casting? */
47 > extern int  castonly;                   /* only doing ray-casting? */
48  
49   int  imm_irrad = 0;                     /* compute immediate irradiance? */
50   int  lim_dist = 0;                      /* limit distance? */
# Line 60 | Line 59 | extern void  tranotify(OBJECT obj);
59   char  *tralist[MAXMODLIST];             /* list of modifers to trace (or no) */
60   int  traincl = -1;                      /* include == 1, exclude == 0 */
61  
62 + double  (*sens_curve)(SCOLOR scol) = NULL;      /* spectral conversion for 1-channel */
63 + double  out_scalefactor = 1;            /* output calibration scale factor */
64 + RGBPRIMP  out_prims = stdprims;         /* output color primitives (NULL if spectral) */
65 + static RGBPRIMS  our_prims;             /* private output color primitives */
66 +
67   static int  loadflags = ~IO_FILES;      /* what to load from octree */
68  
69   static void onsig(int  signo);
70   static void sigdie(int  signo, char  *msg);
71   static void printdefaults(void);
72  
73 + #ifdef PERSIST
74 + #define RTRACE_FEATURES "Persist\nParallelPersist\nMultiprocessing\n" \
75 +                        "IrradianceCalc\nImmediateIrradiance\nDistanceLimiting\n" \
76 +                        "ParticipatingMedia=Mist\n" \
77 +                        "HessianAmbientCache\nAmbientAveraging\n" \
78 +                        "AmbientValueSharing\nAdaptiveShadowTesting\n" \
79 +                        "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \
80 +                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" \
81 +                        "OutputCS=RGB,XYZ,Y,S,M,prims,spec\n"
82 + #else
83 + #define RTRACE_FEATURES "IrradianceCalc\nIrradianceCalc\nDistanceLimiting\n" \
84 +                        "ParticipatingMedia=Mist\n" \
85 +                        "HessianAmbientCache\nAmbientAveraging\n" \
86 +                        "AmbientValueSharing\nAdaptiveShadowTesting\n" \
87 +                        "InputFormats=a,f,d\nOutputFormats=a,f,d,c\n" \
88 +                        "Outputs=o,d,v,V,w,W,l,L,c,p,n,N,s,m,M,r,x,R,X,~\n" \
89 +                        "OutputCS=RGB,XYZ,Y,S,M,prims,spec\n"
90 + #endif
91  
92 +
93   int
94   main(int  argc, char  *argv[])
95   {
# Line 89 | Line 112 | main(int  argc, char  *argv[])
112          int  i;
113                                          /* global program name */
114          progname = argv[0] = fixargv0(argv[0]);
115 +                                        /* feature check only? */
116 +        strcat(RFeatureList, RTRACE_FEATURES);
117 +        if (argc > 1 && !strcmp(argv[1], "-features"))
118 +                return feature_status(argc-2, argv+2);
119                                          /* add trace notify function */
120          for (i = 0; addobjnotify[i] != NULL; i++)
121                  ;
# Line 133 | Line 160 | main(int  argc, char  *argv[])
160                          check(2,"i");
161                          vresolu = atoi(argv[++i]);
162                          break;
163 <                case 'w':                               /* warnings */
163 >                case 'w':                               /* warnings & spectral */
164                          rval = erract[WARNING].pf != NULL;
165                          check_bool(2,rval);
166                          if (rval) erract[WARNING].pf = wputs;
# Line 235 | Line 262 | main(int  argc, char  *argv[])
262                                  goto badopt;
263                          }
264                          break;
265 +                case 'p':                               /* value output */
266 +                        switch (argv[i][2]) {
267 +                        case 'R':                       /* standard RGB output */
268 +                                if (strcmp(argv[i]+2, "RGB"))
269 +                                        goto badopt;
270 +                                out_prims = stdprims;
271 +                                out_scalefactor = 1;
272 +                                sens_curve = NULL;
273 +                                break;
274 +                        case 'X':                       /* XYZ output */
275 +                                if (strcmp(argv[i]+2, "XYZ"))
276 +                                        goto badopt;
277 +                                out_prims = xyzprims;
278 +                                out_scalefactor = WHTEFFICACY;
279 +                                sens_curve = NULL;
280 +                                break;
281 +                        case 'c': {
282 +                                int     j;
283 +                                check(3,"ffffffff");
284 +                                rval = 0;
285 +                                for (j = 0; j < 8; j++) {
286 +                                        our_prims[0][j] = atof(argv[++i]);
287 +                                        rval |= fabs(our_prims[0][j]-stdprims[0][j]) > .001;
288 +                                }
289 +                                if (rval) {
290 +                                        if (!colorprimsOK(our_prims))
291 +                                                error(USER, "illegal primary chromaticities");
292 +                                        out_prims = our_prims;
293 +                                } else
294 +                                        out_prims = stdprims;
295 +                                out_scalefactor = 1;
296 +                                sens_curve = NULL;
297 +                                } break;
298 +                        case 'Y':                       /* photopic response */
299 +                                if (argv[i][3])
300 +                                        goto badopt;
301 +                                sens_curve = scolor_photopic;
302 +                                out_scalefactor = WHTEFFICACY;
303 +                                break;
304 +                        case 'S':                       /* scotopic response */
305 +                                if (argv[i][3])
306 +                                        goto badopt;
307 +                                sens_curve = scolor_scotopic;
308 +                                out_scalefactor = WHTSCOTOPIC;
309 +                                break;
310 +                        case 'M':                       /* melanopic response */
311 +                                if (argv[i][3])
312 +                                        goto badopt;
313 +                                sens_curve = scolor_melanopic;
314 +                                out_scalefactor = WHTMELANOPIC;
315 +                                break;
316 +                        default:
317 +                                goto badopt;
318 +                        }
319 +                        break;
320 + #if MAXCSAMP>3
321 +                case 'c':                               /* output spectral results */
322 +                        if (argv[i][2] != 'o')
323 +                                goto badopt;
324 +                        rval = (out_prims == NULL) & (sens_curve == NULL);
325 +                        check_bool(3,rval);
326 +                        if (rval) {
327 +                                out_prims = NULL;
328 +                                sens_curve = NULL;
329 +                        } else if (out_prims == NULL)
330 +                                out_prims = stdprims;
331 +                        break;
332 + #endif
333   #ifdef  PERSIST
334                  case 'P':                               /* persist file */
335                          if (argv[i][2] == 'P') {
# Line 251 | Line 346 | main(int  argc, char  *argv[])
346                          goto badopt;
347                  }
348          }
349 <        if (nproc > 1) {
350 <                if (persist)
351 <                        error(USER, "multiprocessing incompatible with persist file");
352 <                if (!vresolu && hresolu > 0 && hresolu < nproc)
353 <                        error(WARNING, "number of cores should not exceed horizontal resolution");
354 <                if (trace != NULL)
355 <                        error(WARNING, "multiprocessing does not work properly with trace mode");
356 <        }
349 >                                        /* set/check spectral sampling */
350 >        rval = setspectrsamp(CNDX, WLPART);
351 >        if (rval < 0)
352 >                error(USER, "unsupported spectral sampling");
353 >        if (out_prims != NULL) {
354 >                if (!rval)
355 >                        error(WARNING, "spectral range incompatible with color output");
356 >        } else if (NCSAMP == 3)
357 >                out_prims = stdprims;   /* 3 samples do not a spectrum make */
358 >        if (nproc > 1 && persist)
359 >                error(USER, "multiprocessing incompatible with persist file");
360                                          /* initialize object types */
361          initotypes();
362                                          /* initialize urand */
# Line 317 | Line 415 | main(int  argc, char  *argv[])
415          if (outform != 'a')
416                  SET_FILE_BINARY(stdout);
417          rval = setrtoutput();
418 <        readoct(octname = octnm, loadflags, &thescene, NULL);
418 >        octname = savqstr(octnm);
419 >        readoct(octname, loadflags, &thescene, NULL);
420          nsceneobjs = nobjects;
421  
422          if (loadflags & IO_INFO) {      /* print header */
# Line 325 | Line 424 | main(int  argc, char  *argv[])
424                  printf("SOFTWARE= %s\n", VersionID);
425                  fputnow(stdout);
426                  if (rval > 0)           /* saved from setrtoutput() call */
427 <                        printf("NCOMP=%d\n", rval);
427 >                        fputncomp(rval, stdout);
428 >                if (NCSAMP > 3)
429 >                        fputwlsplit(WLPART, stdout);
430 >                if ((out_prims != stdprims) & (out_prims != NULL))
431 >                        fputprims(out_prims, stdout);
432                  if ((outform == 'f') | (outform == 'd'))
433                          fputendian(stdout);
434                  fputformat(formstr(outform), stdout);
435 <                putchar('\n');
435 >                fputc('\n', stdout);    /* end of header */
436          }
437  
438          if (!castonly) {        /* any actual ray traversal to do? */
# Line 339 | Line 442 | main(int  argc, char  *argv[])
442                  marksources();          /* find and mark sources */
443  
444                  setambient();           /* initialize ambient calculation */
445 <        }
445 >        } else
446 >                distantsources();       /* else mark only distant sources */
447 >
448 >        fflush(stdout);                 /* in case we're duplicating header */
449 >
450   #ifdef  PERSIST
451          if (persist) {
345                fflush(stdout);
452                                                  /* reconnect stdout */
453                  dup2(duped1, fileno(stdout));
454                  close(duped1);
# Line 402 | Line 508 | badopt:
508  
509   void
510   wputs(                          /* warning output function */
511 <        char    *s
511 >        const char      *s
512   )
513   {
514          int  lasterrno = errno;
# Line 413 | Line 519 | wputs(                         /* warning output function */
519  
520   void
521   eputs(                          /* put string to stderr */
522 <        register char  *s
522 >        const char  *s
523   )
524   {
525          static int  midline = 0;
# Line 468 | Line 574 | sigdie(                        /* set fatal signal */
574   static void
575   printdefaults(void)                     /* print default values to stdout */
576   {
577 <        register char  *cp;
577 >        char  *cp;
578  
579 +        printf(erract[WARNING].pf != NULL ?
580 +                        "-w+\t\t\t\t# warning messages on\n" :
581 +                        "-w-\t\t\t\t# warning messages off\n");
582          if (imm_irrad)
583                  printf("-I+\t\t\t\t# immediate irradiance on\n");
584          printf("-n %-2d\t\t\t\t# number of rendering processes\n", nproc);
# Line 478 | Line 587 | printdefaults(void)                    /* print default values to stdou
587          printf("-y %-9d\t\t\t# y resolution\n", vresolu);
588          printf(lim_dist ? "-ld+\t\t\t\t# limit distance on\n" :
589                          "-ld-\t\t\t\t# limit distance off\n");
590 <        printf("-h%c\t\t\t\t# %s header\n", loadflags & IO_INFO ? '+' : '-',
591 <                        loadflags & IO_INFO ? "output" : "no");
590 >        printf(loadflags & IO_INFO ? "-h+\t\t\t\t# output header\n" :
591 >                        "-h-\t\t\t\t# no header\n");
592          printf("-f%c%c\t\t\t\t# format input/output = %s/%s\n",
593                          inform, outform, formstr(inform), formstr(outform));
594          printf("-o%-9s\t\t\t# output", outvals);
# Line 504 | Line 613 | printdefaults(void)                    /* print default values to stdou
613                  case 'W': printf(" coefficient"); break;
614                  case 'm': printf(" modifier"); break;
615                  case 'M': printf(" material"); break;
616 <                case '-': printf(" stroke"); break;
616 >                case '~': printf(" tilde"); break;
617                  }
618 <        putchar('\n');
619 <        printf(erract[WARNING].pf != NULL ?
620 <                        "-w+\t\t\t\t# warning messages on\n" :
621 <                        "-w-\t\t\t\t# warning messages off\n");
618 >        fputc('\n', stdout);
619 >        if (sens_curve == scolor_photopic)
620 >                printf("-pY\t\t\t\t# photopic output\n");
621 >        else if (sens_curve == scolor_scotopic)
622 >                printf("-pS\t\t\t\t# scotopic output\n");
623 >        else if (sens_curve == scolor_melanopic)
624 >                printf("-pM\t\t\t\t# melanopic output\n");
625 >        else if (out_prims == stdprims)
626 >                printf("-pRGB\t\t\t\t# standard RGB color output\n");
627 >        else if (out_prims == xyzprims)
628 >                printf("-pXYZ\t\t\t\t# CIE XYZ color output\n");
629 >        else if (out_prims != NULL)
630 >                printf("-pc %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\t# output color primaries and white point\n",
631 >                                out_prims[RED][0], out_prims[RED][1],
632 >                                out_prims[GRN][0], out_prims[GRN][1],
633 >                                out_prims[BLU][0], out_prims[BLU][1],
634 >                                out_prims[WHT][0], out_prims[WHT][1]);
635 >        if ((sens_curve == NULL) & (NCSAMP > 3))
636 >                printf(out_prims != NULL ? "-co-\t\t\t\t# output tristimulus colors\n" :
637 >                                "-co+\t\t\t\t# output spectral values\n");
638          print_rdefaults();
639   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines