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.8 by greg, Tue May 31 18:01:09 2005 UTC vs.
Revision 2.27 by greg, Tue Apr 22 17:12:25 2025 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines