ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/renderopts.c
Revision: 2.12
Committed: Tue Jun 14 04:04:51 2005 UTC (18 years, 9 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R7P2, rad3R7P1
Changes since 2.11: +2 -2 lines
Log Message:
Changed wording in -defaults output (again)

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: renderopts.c,v 2.11 2005/06/14 03:53:58 greg Exp $";
3 #endif
4 /*
5 * renderopts.c - process common rendering options
6 *
7 * External symbols declared in ray.h
8 */
9
10 #include "copyright.h"
11
12 #include "ray.h"
13 #include "paths.h"
14
15
16 extern int
17 getrenderopt( /* get next render option */
18 int ac,
19 char *av[]
20 )
21 {
22 #define check(ol,al) if (av[0][ol] || \
23 badarg(ac-1,av+1,al)) \
24 return(-1)
25 #define bool(olen,var) switch (av[0][olen]) { \
26 case '\0': var = !var; break; \
27 case 'y': case 'Y': case 't': case 'T': \
28 case '+': case '1': var = 1; break; \
29 case 'n': case 'N': case 'f': case 'F': \
30 case '-': case '0': var = 0; break; \
31 default: return(-1); }
32 static char **amblp; /* pointer to build ambient list */
33 int rval;
34 /* is it even an option? */
35 if (ac < 1 || av[0] == NULL || av[0][0] != '-')
36 return(-1);
37 /* check if it's one we know */
38 switch (av[0][1]) {
39 case 'u': /* uncorrelated sampling */
40 bool(2,rand_samp);
41 return(0);
42 case 'b': /* back face vis. */
43 if (av[0][2] == 'v') {
44 bool(3,backvis);
45 return(0);
46 }
47 break;
48 case 'd': /* direct */
49 switch (av[0][2]) {
50 case 't': /* threshold */
51 check(3,"f");
52 shadthresh = atof(av[1]);
53 return(1);
54 case 'c': /* certainty */
55 check(3,"f");
56 shadcert = atof(av[1]);
57 return(1);
58 case 'j': /* jitter */
59 check(3,"f");
60 dstrsrc = atof(av[1]);
61 return(1);
62 case 'r': /* relays */
63 check(3,"i");
64 directrelay = atoi(av[1]);
65 return(1);
66 case 'p': /* pretest */
67 check(3,"i");
68 vspretest = atoi(av[1]);
69 return(1);
70 case 'v': /* visibility */
71 bool(3,directvis);
72 return(0);
73 case 's': /* size */
74 check(3,"f");
75 srcsizerat = atof(av[1]);
76 return(1);
77 }
78 break;
79 case 's': /* specular */
80 switch (av[0][2]) {
81 case 't': /* threshold */
82 check(3,"f");
83 specthresh = atof(av[1]);
84 return(1);
85 case 'j': /* jitter */
86 check(3,"f");
87 specjitter = atof(av[1]);
88 return(1);
89 }
90 break;
91 case 'l': /* limit */
92 switch (av[0][2]) {
93 case 'r': /* recursion */
94 check(3,"i");
95 maxdepth = atoi(av[1]);
96 return(1);
97 case 'w': /* weight */
98 check(3,"f");
99 minweight = atof(av[1]);
100 return(1);
101 }
102 break;
103 case 'i': /* irradiance */
104 bool(2,do_irrad);
105 return(0);
106 case 'a': /* ambient */
107 switch (av[0][2]) {
108 case 'v': /* value */
109 check(3,"fff");
110 setcolor(ambval, atof(av[1]),
111 atof(av[2]),
112 atof(av[3]));
113 return(3);
114 case 'w': /* weight */
115 check(3,"i");
116 ambvwt = atoi(av[1]);
117 return(1);
118 case 'a': /* accuracy */
119 check(3,"f");
120 ambacc = atof(av[1]);
121 return(1);
122 case 'r': /* resolution */
123 check(3,"i");
124 ambres = atoi(av[1]);
125 return(1);
126 case 'd': /* divisions */
127 check(3,"i");
128 ambdiv = atoi(av[1]);
129 return(1);
130 case 's': /* super-samp */
131 check(3,"i");
132 ambssamp = atoi(av[1]);
133 return(1);
134 case 'b': /* bounces */
135 check(3,"i");
136 ambounce = atoi(av[1]);
137 return(1);
138 case 'i': /* include */
139 case 'I':
140 check(3,"s");
141 if (ambincl != 1) {
142 ambincl = 1;
143 amblp = amblist;
144 }
145 if (av[0][2] == 'I') { /* file */
146 rval = wordfile(amblp,
147 getpath(av[1],getrlibpath(),R_OK));
148 if (rval < 0) {
149 sprintf(errmsg,
150 "cannot open ambient include file \"%s\"", av[1]);
151 error(SYSTEM, errmsg);
152 }
153 amblp += rval;
154 } else {
155 *amblp++ = savqstr(av[1]);
156 *amblp = NULL;
157 }
158 return(1);
159 case 'e': /* exclude */
160 case 'E':
161 check(3,"s");
162 if (ambincl != 0) {
163 ambincl = 0;
164 amblp = amblist;
165 }
166 if (av[0][2] == 'E') { /* file */
167 rval = wordfile(amblp,
168 getpath(av[1],getrlibpath(),R_OK));
169 if (rval < 0) {
170 sprintf(errmsg,
171 "cannot open ambient exclude file \"%s\"", av[1]);
172 error(SYSTEM, errmsg);
173 }
174 amblp += rval;
175 } else {
176 *amblp++ = savqstr(av[1]);
177 *amblp = NULL;
178 }
179 return(1);
180 case 'f': /* file */
181 check(3,"s");
182 ambfile = savqstr(av[1]);
183 return(1);
184 }
185 break;
186 case 'm': /* medium */
187 switch (av[0][2]) {
188 case 'e': /* extinction */
189 check(3,"fff");
190 setcolor(cextinction, atof(av[1]),
191 atof(av[2]),
192 atof(av[3]));
193 return(3);
194 case 'a': /* albedo */
195 check(3,"fff");
196 setcolor(salbedo, atof(av[1]),
197 atof(av[2]),
198 atof(av[3]));
199 return(3);
200 case 'g': /* eccentr. */
201 check(3,"f");
202 seccg = atof(av[1]);
203 return(1);
204 case 's': /* sampling */
205 check(3,"f");
206 ssampdist = atof(av[1]);
207 return(1);
208 }
209 break;
210 }
211 return(-1); /* unknown option */
212
213 #undef check
214 #undef bool
215 }
216
217
218 extern void
219 print_rdefaults(void) /* print default render values to stdout */
220 {
221 printf(do_irrad ? "-i+\t\t\t\t# irradiance calculation on\n" :
222 "-i-\t\t\t\t# irradiance calculation off\n");
223 printf(rand_samp ? "-u+\t\t\t\t# uncorrelated Monte Carlo sampling\n" :
224 "-u-\t\t\t\t# correlated quasi-Monte Carlo sampling\n");
225 printf(backvis ? "-bv+\t\t\t\t# back face visibility on\n" :
226 "-bv-\t\t\t\t# back face visibility off\n");
227 printf("-dt %f\t\t\t# direct threshold\n", shadthresh);
228 printf("-dc %f\t\t\t# direct certainty\n", shadcert);
229 printf("-dj %f\t\t\t# direct jitter\n", dstrsrc);
230 printf("-ds %f\t\t\t# direct sampling\n", srcsizerat);
231 printf("-dr %-9d\t\t\t# direct relays\n", directrelay);
232 printf("-dp %-9d\t\t\t# direct pretest density\n", vspretest);
233 printf(directvis ? "-dv+\t\t\t\t# direct visibility on\n" :
234 "-dv-\t\t\t\t# direct visibility off\n");
235 printf("-sj %f\t\t\t# specular jitter\n", specjitter);
236 printf("-st %f\t\t\t# specular threshold\n", specthresh);
237 printf("-av %f %f %f\t# ambient value\n", colval(ambval,RED),
238 colval(ambval,GRN), colval(ambval, BLU));
239 printf("-aw %-9d\t\t\t# ambient value weight\n", ambvwt);
240 printf("-ab %-9d\t\t\t# ambient bounces\n", ambounce);
241 printf("-aa %f\t\t\t# ambient accuracy\n", ambacc);
242 printf("-ar %-9d\t\t\t# ambient resolution\n", ambres);
243 printf("-ad %-9d\t\t\t# ambient divisions\n", ambdiv);
244 printf("-as %-9d\t\t\t# ambient super-samples\n", ambssamp);
245 printf("-me %.2e %.2e %.2e\t# mist extinction coefficient\n",
246 colval(cextinction,RED),
247 colval(cextinction,GRN),
248 colval(cextinction,BLU));
249 printf("-ma %f %f %f\t# mist scattering albedo\n", colval(salbedo,RED),
250 colval(salbedo,GRN), colval(salbedo,BLU));
251 printf("-mg %f\t\t\t# mist scattering eccentricity\n", seccg);
252 printf("-ms %f\t\t\t# mist sampling distance\n", ssampdist);
253 printf("-lr %-9d\t\t\t# limit reflection%s\n", maxdepth,
254 maxdepth<=0 ? " (Russian roulette)" : "");
255 printf("-lw %f\t\t\t# limit weight\n", minweight);
256 }