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

Comparing ray/src/rt/renderopts.c (file contents):
Revision 2.10 by greg, Tue Jun 14 03:34:14 2005 UTC vs.
Revision 2.23 by greg, Fri Nov 17 20:02:07 2023 UTC

# Line 11 | Line 11 | static const char      RCSid[] = "$Id$";
11  
12   #include  "ray.h"
13   #include  "paths.h"
14 + #include  "pmapopt.h"
15  
16 + extern char     *progname;      /* global argv[0] */
17  
18 < extern int
18 > char    RFeatureList[2048] =    /* newline-separated feature list */
19 >                "VirtualSources\nSecondarySources\nSourceSubsampling\n"
20 >                "SourceVisibility\nAmbientModifierSelection\n"
21 >                "PathTracing\nRussianRoulette\nLowDiscrepancySeq\n"
22 >                "SpecularSampling\nMaterialMixtures\nAntimatter\nBackFaceVisibility\n"
23 >                "ScatteringModels=WGMD,Ashikhmin-Shirley\n"
24 >                "TabulatedBSDFs=DataFile,KlemsXML,TensorTreeXML,+ViewPeakExtraction\n"
25 >                "Instancing=Octree,TriangleMesh\nAliases\n"
26 > #if MAXCSAMP>3
27 >                "Hyperspectral\n"
28 > #endif
29 > #if !defined(SHADCACHE) || SHADCACHE > 0
30 >                "ShadowCache\n"
31 > #endif
32 > #ifdef  DISPERSE
33 >                "DielectricDispersion\n"
34 > #endif
35 > /*              PMAP_FEATURES   XXX @Roland: need to define this in pmapopt.h */
36 > ;
37 >
38 >
39 > static char *
40 > get_feature(            /* find a specific feature (with optional sublist) */
41 >        const char *feat
42 > )
43 > {
44 >        char    *cp = RFeatureList;
45 >        int     n = 0;
46 >
47 >        while ((feat[n] != '\0') & (feat[n] != '='))
48 >                n++;
49 >        if (!n)
50 >                return(NULL);
51 >        while (*cp) {
52 >                if (!strncmp(cp, feat, n) && (cp[n] == '\n') | !feat[n] | (cp[n] == feat[n]))
53 >                        return(cp);
54 >                while (*cp++ != '\n')
55 >                        ;
56 >        }
57 >        return(NULL);
58 > }
59 >
60 >
61 > static int
62 > match_subfeatures(      /* check if subfeatures are supported */
63 >        char *mysublist,
64 >        char *reqs
65 > )
66 > {
67 >        if (mysublist)
68 >                mysublist = strchr(mysublist, '=');
69 >        if (!mysublist++ | !reqs)
70 >                return(0);              /* not a feature list */
71 >        while (*reqs) {                 /* check each of their subfeature requests */
72 >                char    subfeat[64];
73 >                char    *cp = subfeat;
74 >                int     n;
75 >                while (*reqs && (*cp = *reqs++) != ',')
76 >                        cp++;
77 >                *cp = '\0';
78 >                n = cp - subfeat;
79 >                if (!(cp = strstr(mysublist, subfeat)) ||
80 >                                (cp[-1] != ',') & (cp[-1] != '=') ||
81 >                                (cp[n] != ',') & (cp[n] != '\n'))
82 >                        return(0);      /* missing this one! */
83 >        }
84 >        return(1);                      /* matched them all */
85 > }
86 >
87 >
88 > int
89 > feature_status(         /* report active feature list / check specifics */
90 >        int  ac,
91 >        char  *av[]
92 > )
93 > {
94 >        if (ac <= 0)                    /* report entire list? */
95 >                fputs(RFeatureList, stdout);
96 >
97 >        for ( ; ac-- > 0; av++) {       /* check each argument */
98 >                char    *cp;
99 >                if (!*av[0]) continue;
100 >                if ((cp = strchr(av[0], '=')) != NULL) {
101 >                        if (!match_subfeatures(get_feature(av[0]), cp+1))
102 >                                goto missing_feature;
103 >                } else if ((cp = get_feature(av[0])) != NULL) {
104 >                        char    *tp = strchr(cp, '=');
105 >                        if (tp && tp < strchr(cp, '\n'))
106 >                                do
107 >                                        fputc(*cp, stdout);
108 >                                while (*cp++ != '\n');
109 >                } else
110 >                        goto missing_feature;
111 >        }
112 >        return(0);                      /* return satisfactory status */
113 > missing_feature:                        /* or report error */
114 >        fprintf(stderr, "%s: missing feature - %s\n", progname, av[0]);
115 >        return(1);
116 > }
117 >
118 >
119 > int
120   getrenderopt(           /* get next render option */
121          int  ac,
122          char  *av[]
# Line 22 | Line 125 | getrenderopt(          /* get next render option */
125   #define  check(ol,al)           if (av[0][ol] || \
126                                  badarg(ac-1,av+1,al)) \
127                                  return(-1)
128 < #define  bool(olen,var)         switch (av[0][olen]) { \
128 > #define  check_bool(olen,var)           switch (av[0][olen]) { \
129                                  case '\0': var = !var; break; \
130                                  case 'y': case 'Y': case 't': case 'T': \
131                                  case '+': case '1': var = 1; break; \
# Line 37 | Line 140 | getrenderopt(          /* get next render option */
140                                          /* check if it's one we know */
141          switch (av[0][1]) {
142          case 'u':                               /* uncorrelated sampling */
143 <                bool(2,rand_samp);
143 >                check_bool(2,rand_samp);
144                  return(0);
145          case 'b':                               /* back face vis. */
146                  if (av[0][2] == 'v') {
147 <                        bool(3,backvis);
147 >                        check_bool(3,backvis);
148                          return(0);
149                  }
150                  break;
# Line 68 | Line 171 | getrenderopt(          /* get next render option */
171                          vspretest = atoi(av[1]);
172                          return(1);
173                  case 'v':                               /* visibility */
174 <                        bool(3,directvis);
174 >                        check_bool(3,directvis);
175                          return(0);
176                  case 's':                               /* size */
177                          check(3,"f");
# Line 82 | Line 185 | getrenderopt(          /* get next render option */
185                          check(3,"f");
186                          specthresh = atof(av[1]);
187                          return(1);
188 <                case 'j':                               /* jitter */
188 >                case 's':                               /* sampling */
189                          check(3,"f");
190                          specjitter = atof(av[1]);
191                          return(1);
# Line 101 | Line 204 | getrenderopt(          /* get next render option */
204                  }
205                  break;
206          case 'i':                               /* irradiance */
207 <                bool(2,do_irrad);
207 >                check_bool(2,do_irrad);
208                  return(0);
209          case 'a':                               /* ambient */
210                  switch (av[0][2]) {
# Line 143 | Line 246 | getrenderopt(          /* get next render option */
246                                  amblp = amblist;
247                          }
248                          if (av[0][2] == 'I') {  /* file */
249 <                                rval = wordfile(amblp,
249 >                                rval = wordfile(amblp, AMBLLEN-(amblp-amblist),
250                                          getpath(av[1],getrlibpath(),R_OK));
251                                  if (rval < 0) {
252                                          sprintf(errmsg,
# Line 164 | Line 267 | getrenderopt(          /* get next render option */
267                                  amblp = amblist;
268                          }
269                          if (av[0][2] == 'E') {  /* file */
270 <                                rval = wordfile(amblp,
270 >                                rval = wordfile(amblp, AMBLLEN-(amblp-amblist),
271                                          getpath(av[1],getrlibpath(),R_OK));
272                                  if (rval < 0) {
273                                          sprintf(errmsg,
# Line 207 | Line 310 | getrenderopt(          /* get next render option */
310                          return(1);
311                  }
312                  break;
313 + #if MAXCSAMP>3
314 +        case 'c':                               /* spectral sampling */
315 +                switch (av[0][2]) {
316 +                case 's':                       /* spectral bin count */
317 +                        check(3,"i");
318 +                        NCSAMP = atoi(av[1]);
319 +                        return(1);
320 +                case 'w':                       /* wavelength extrema */
321 +                        check(3,"ff");
322 +                        WLPART[0] = atof(av[1]);
323 +                        WLPART[3] = atof(av[2]);
324 +                        return(1);
325 +                }
326 +                break;
327 + #endif
328          }
329 <        return(-1);             /* unknown option */
329 >        
330 >        /* PMAP: Parse photon mapping options */
331 >        return(getPmapRenderOpt(ac, av));
332 >        
333 > /*      return(-1); */          /* unknown option */
334  
335   #undef  check
336 < #undef  bool
336 > #undef  check_bool
337   }
338  
339  
340 < extern void
340 > void
341   print_rdefaults(void)           /* print default render values to stdout */
342   {
343          printf(do_irrad ? "-i+\t\t\t\t# irradiance calculation on\n" :
344                          "-i-\t\t\t\t# irradiance calculation off\n");
345 <        printf(rand_samp ? "-u+\t\t\t\t# uncorrelated sampling on\n" :
346 <                        "-u-\t\t\t\t# uncorrelated sampling off\n");
345 >        printf(rand_samp ? "-u+\t\t\t\t# uncorrelated Monte Carlo sampling\n" :
346 >                        "-u-\t\t\t\t# correlated quasi-Monte Carlo sampling\n");
347          printf(backvis ? "-bv+\t\t\t\t# back face visibility on\n" :
348                          "-bv-\t\t\t\t# back face visibility off\n");
349          printf("-dt %f\t\t\t# direct threshold\n", shadthresh);
# Line 232 | Line 354 | print_rdefaults(void)          /* print default render values
354          printf("-dp %-9d\t\t\t# direct pretest density\n", vspretest);
355          printf(directvis ? "-dv+\t\t\t\t# direct visibility on\n" :
356                          "-dv-\t\t\t\t# direct visibility off\n");
357 <        printf("-sj %f\t\t\t# specular jitter\n", specjitter);
357 >        printf("-ss %f\t\t\t# specular sampling\n", specjitter);
358          printf("-st %f\t\t\t# specular threshold\n", specthresh);
359          printf("-av %f %f %f\t# ambient value\n", colval(ambval,RED),
360                          colval(ambval,GRN), colval(ambval, BLU));
# Line 250 | Line 372 | print_rdefaults(void)          /* print default render values
372                          colval(salbedo,GRN), colval(salbedo,BLU));
373          printf("-mg %f\t\t\t# mist scattering eccentricity\n", seccg);
374          printf("-ms %f\t\t\t# mist sampling distance\n", ssampdist);
375 +        if (NCSAMP > 3) {
376 +                printf("-cs %-2d\t\t\t\t# number of spectral bins\n", NCSAMP);
377 +                printf("-cw %3.0f %3.0f\t\t\t# wavelength limits (nm)\n",
378 +                                WLPART[3], WLPART[0]);
379 +        }
380          printf("-lr %-9d\t\t\t# limit reflection%s\n", maxdepth,
381                          maxdepth<=0 ? " (Russian roulette)" : "");
382 <        printf("-lw %f\t\t\t# limit weight\n", minweight);
382 >        printf("-lw %.2e\t\t\t# limit weight\n", minweight);
383 >        
384 >        /* PMAP: output photon map defaults */
385 >        printPmapDefaults();
386   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines