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.12 by greg, Tue Jun 14 04:04:51 2005 UTC vs.
Revision 2.26 by greg, Fri Apr 5 17:55:25 2024 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 >                if (!(n = cp - subfeat))
79 >                        continue;       /* empty subfeature */
80 >                for (cp = mysublist; (cp = strstr(cp, subfeat)) != NULL; cp++)
81 >                        if ((cp[-1] == ',') | (cp[-1] == '=') &&
82 >                                        (cp[n] == ',') | (cp[n] == '\n'))
83 >                                break;  /* match */
84 >                if (!cp)
85 >                        return(0);      /* missing this one! */
86 >        }
87 >        return(1);                      /* matched them all */
88 > }
89 >
90 >
91 > int
92 > feature_status(         /* report active feature list / check specifics */
93 >        int  ac,
94 >        char  *av[]
95 > )
96 > {
97 >        if (ac <= 0)                    /* report entire list? */
98 >                fputs(RFeatureList, stdout);
99 >
100 >        for ( ; ac-- > 0; av++) {       /* check each argument */
101 >                char    *cp;
102 >                if (!*av[0]) continue;
103 >                if ((cp = strchr(av[0], '=')) != NULL) {
104 >                        if (!match_subfeatures(get_feature(av[0]), cp+1))
105 >                                goto missing_feature;
106 >                } else if ((cp = get_feature(av[0])) != NULL) {
107 >                        char    *tp = strchr(cp, '=');
108 >                        if (tp && tp < strchr(cp, '\n'))
109 >                                do
110 >                                        fputc(*cp, stdout);
111 >                                while (*cp++ != '\n');
112 >                } else
113 >                        goto missing_feature;
114 >        }
115 >        return(0);                      /* return satisfactory status */
116 > missing_feature:                        /* or report error */
117 >        fprintf(stderr, "%s: missing feature - %s\n", progname, av[0]);
118 >        return(1);
119 > }
120 >
121 >
122 > int
123   getrenderopt(           /* get next render option */
124          int  ac,
125          char  *av[]
# Line 22 | Line 128 | getrenderopt(          /* get next render option */
128   #define  check(ol,al)           if (av[0][ol] || \
129                                  badarg(ac-1,av+1,al)) \
130                                  return(-1)
131 < #define  bool(olen,var)         switch (av[0][olen]) { \
131 > #define  check_bool(olen,var)           switch (av[0][olen]) { \
132                                  case '\0': var = !var; break; \
133                                  case 'y': case 'Y': case 't': case 'T': \
134                                  case '+': case '1': var = 1; break; \
# Line 37 | Line 143 | getrenderopt(          /* get next render option */
143                                          /* check if it's one we know */
144          switch (av[0][1]) {
145          case 'u':                               /* uncorrelated sampling */
146 <                bool(2,rand_samp);
146 >                check_bool(2,rand_samp);
147                  return(0);
148          case 'b':                               /* back face vis. */
149                  if (av[0][2] == 'v') {
150 <                        bool(3,backvis);
150 >                        check_bool(3,backvis);
151                          return(0);
152                  }
153                  break;
# Line 68 | Line 174 | getrenderopt(          /* get next render option */
174                          vspretest = atoi(av[1]);
175                          return(1);
176                  case 'v':                               /* visibility */
177 <                        bool(3,directvis);
177 >                        check_bool(3,directvis);
178                          return(0);
179                  case 's':                               /* size */
180                          check(3,"f");
# Line 82 | Line 188 | getrenderopt(          /* get next render option */
188                          check(3,"f");
189                          specthresh = atof(av[1]);
190                          return(1);
191 <                case 'j':                               /* jitter */
191 >                case 's':                               /* sampling */
192                          check(3,"f");
193                          specjitter = atof(av[1]);
194                          return(1);
# Line 101 | Line 207 | getrenderopt(          /* get next render option */
207                  }
208                  break;
209          case 'i':                               /* irradiance */
210 <                bool(2,do_irrad);
210 >                check_bool(2,do_irrad);
211                  return(0);
212          case 'a':                               /* ambient */
213                  switch (av[0][2]) {
# Line 143 | Line 249 | getrenderopt(          /* get next render option */
249                                  amblp = amblist;
250                          }
251                          if (av[0][2] == 'I') {  /* file */
252 <                                rval = wordfile(amblp,
252 >                                rval = wordfile(amblp, AMBLLEN-(amblp-amblist),
253                                          getpath(av[1],getrlibpath(),R_OK));
254                                  if (rval < 0) {
255                                          sprintf(errmsg,
# Line 164 | Line 270 | getrenderopt(          /* get next render option */
270                                  amblp = amblist;
271                          }
272                          if (av[0][2] == 'E') {  /* file */
273 <                                rval = wordfile(amblp,
273 >                                rval = wordfile(amblp, AMBLLEN-(amblp-amblist),
274                                          getpath(av[1],getrlibpath(),R_OK));
275                                  if (rval < 0) {
276                                          sprintf(errmsg,
# Line 207 | Line 313 | getrenderopt(          /* get next render option */
313                          return(1);
314                  }
315                  break;
316 + #if MAXCSAMP>3
317 +        case 'c':                               /* spectral sampling */
318 +                switch (av[0][2]) {
319 +                case 's':                       /* spectral bin count */
320 +                        check(3,"i");
321 +                        NCSAMP = atoi(av[1]);
322 +                        return(1);
323 +                case 'w':                       /* wavelength extrema */
324 +                        check(3,"ff");
325 +                        WLPART[0] = atof(av[1]);
326 +                        WLPART[3] = atof(av[2]);
327 +                        return(2);
328 +                }
329 +                break;
330 + #endif
331          }
332 <        return(-1);             /* unknown option */
332 >        
333 >        /* PMAP: Parse photon mapping options */
334 >        return(getPmapRenderOpt(ac, av));
335 >        
336 > /*      return(-1); */          /* unknown option */
337  
338   #undef  check
339 < #undef  bool
339 > #undef  check_bool
340   }
341  
342  
343 < extern void
343 > void
344   print_rdefaults(void)           /* print default render values to stdout */
345   {
346          printf(do_irrad ? "-i+\t\t\t\t# irradiance calculation on\n" :
# Line 232 | Line 357 | print_rdefaults(void)          /* print default render values
357          printf("-dp %-9d\t\t\t# direct pretest density\n", vspretest);
358          printf(directvis ? "-dv+\t\t\t\t# direct visibility on\n" :
359                          "-dv-\t\t\t\t# direct visibility off\n");
360 <        printf("-sj %f\t\t\t# specular jitter\n", specjitter);
360 >        printf("-ss %f\t\t\t# specular sampling\n", specjitter);
361          printf("-st %f\t\t\t# specular threshold\n", specthresh);
362          printf("-av %f %f %f\t# ambient value\n", colval(ambval,RED),
363                          colval(ambval,GRN), colval(ambval, BLU));
# Line 250 | Line 375 | print_rdefaults(void)          /* print default render values
375                          colval(salbedo,GRN), colval(salbedo,BLU));
376          printf("-mg %f\t\t\t# mist scattering eccentricity\n", seccg);
377          printf("-ms %f\t\t\t# mist sampling distance\n", ssampdist);
378 +        if (NCSAMP > 3) {
379 +                printf("-cs %-2d\t\t\t\t# number of spectral bins\n", NCSAMP);
380 +                printf("-cw %3.0f %3.0f\t\t\t# wavelength limits (nm)\n",
381 +                                WLPART[3], WLPART[0]);
382 +        }
383          printf("-lr %-9d\t\t\t# limit reflection%s\n", maxdepth,
384                          maxdepth<=0 ? " (Russian roulette)" : "");
385 <        printf("-lw %f\t\t\t# limit weight\n", minweight);
385 >        printf("-lw %.2e\t\t\t# limit weight\n", minweight);
386 >        
387 >        /* PMAP: output photon map defaults */
388 >        printPmapDefaults();
389   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines