7 |
|
* External symbols declared in ray.h |
8 |
|
*/ |
9 |
|
|
10 |
< |
/* ==================================================================== |
11 |
< |
* The Radiance Software License, Version 1.0 |
12 |
< |
* |
13 |
< |
* Copyright (c) 1990 - 2002 The Regents of the University of California, |
14 |
< |
* through Lawrence Berkeley National Laboratory. All rights reserved. |
15 |
< |
* |
16 |
< |
* Redistribution and use in source and binary forms, with or without |
17 |
< |
* modification, are permitted provided that the following conditions |
18 |
< |
* are met: |
19 |
< |
* |
20 |
< |
* 1. Redistributions of source code must retain the above copyright |
21 |
< |
* notice, this list of conditions and the following disclaimer. |
22 |
< |
* |
23 |
< |
* 2. Redistributions in binary form must reproduce the above copyright |
24 |
< |
* notice, this list of conditions and the following disclaimer in |
25 |
< |
* the documentation and/or other materials provided with the |
26 |
< |
* distribution. |
27 |
< |
* |
28 |
< |
* 3. The end-user documentation included with the redistribution, |
29 |
< |
* if any, must include the following acknowledgment: |
30 |
< |
* "This product includes Radiance software |
31 |
< |
* (http://radsite.lbl.gov/) |
32 |
< |
* developed by the Lawrence Berkeley National Laboratory |
33 |
< |
* (http://www.lbl.gov/)." |
34 |
< |
* Alternately, this acknowledgment may appear in the software itself, |
35 |
< |
* if and wherever such third-party acknowledgments normally appear. |
36 |
< |
* |
37 |
< |
* 4. The names "Radiance," "Lawrence Berkeley National Laboratory" |
38 |
< |
* and "The Regents of the University of California" must |
39 |
< |
* not be used to endorse or promote products derived from this |
40 |
< |
* software without prior written permission. For written |
41 |
< |
* permission, please contact [email protected]. |
42 |
< |
* |
43 |
< |
* 5. Products derived from this software may not be called "Radiance", |
44 |
< |
* nor may "Radiance" appear in their name, without prior written |
45 |
< |
* permission of Lawrence Berkeley National Laboratory. |
46 |
< |
* |
47 |
< |
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
48 |
< |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
49 |
< |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
50 |
< |
* DISCLAIMED. IN NO EVENT SHALL Lawrence Berkeley National Laboratory OR |
51 |
< |
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
52 |
< |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
53 |
< |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
54 |
< |
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
55 |
< |
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
56 |
< |
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
57 |
< |
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
58 |
< |
* SUCH DAMAGE. |
59 |
< |
* ==================================================================== |
60 |
< |
* |
61 |
< |
* This software consists of voluntary contributions made by many |
62 |
< |
* individuals on behalf of Lawrence Berkeley National Laboratory. For more |
63 |
< |
* information on Lawrence Berkeley National Laboratory, please see |
64 |
< |
* <http://www.lbl.gov/>. |
65 |
< |
*/ |
10 |
> |
#include "copyright.h" |
11 |
|
|
12 |
|
#include "ray.h" |
13 |
+ |
#include "paths.h" |
14 |
+ |
#include "pmapopt.h" |
15 |
|
|
16 |
+ |
extern char *progname; /* global argv[0] */ |
17 |
|
|
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 |
+ |
"ParticipatingMedia=Mist\nScatteringModels=WGMD,Ashikhmin-Shirley\n" |
24 |
+ |
"TabulatedBSDFs=DataFile,KlemsXML,TensorTreeXML,+ViewPeakExtraction\n" |
25 |
+ |
"Instancing=Octree,TriangleMesh\nAliases\n" |
26 |
+ |
#if !defined(SHADCACHE) || SHADCACHE > 0 |
27 |
+ |
"ShadowCache\n" |
28 |
+ |
#endif |
29 |
+ |
#ifdef DISPERSE |
30 |
+ |
"DielectricDispersion\n" |
31 |
+ |
#endif |
32 |
+ |
/* PMAP_FEATURES XXX @Roland: need to define this in pmapopt.h */ |
33 |
+ |
; |
34 |
+ |
|
35 |
+ |
|
36 |
+ |
static char * |
37 |
+ |
get_feature( /* find a specific feature (with optional sublist) */ |
38 |
+ |
const char *feat |
39 |
+ |
) |
40 |
+ |
{ |
41 |
+ |
char *cp = RFeatureList; |
42 |
+ |
int n = 0; |
43 |
+ |
|
44 |
+ |
while ((feat[n] != '\0') & (feat[n] != '=')) |
45 |
+ |
n++; |
46 |
+ |
if (!n) |
47 |
+ |
return(NULL); |
48 |
+ |
while (*cp) { |
49 |
+ |
if (!strncmp(cp, feat, n) && (cp[n] == '\n') | !feat[n] | (cp[n] == feat[n])) |
50 |
+ |
return(cp); |
51 |
+ |
while (*cp++ != '\n') |
52 |
+ |
; |
53 |
+ |
} |
54 |
+ |
return(NULL); |
55 |
+ |
} |
56 |
+ |
|
57 |
+ |
|
58 |
+ |
static int |
59 |
+ |
match_subfeatures( /* check if subfeatures are supported */ |
60 |
+ |
char *mysublist, |
61 |
+ |
char *reqs |
62 |
+ |
) |
63 |
+ |
{ |
64 |
+ |
if (mysublist) |
65 |
+ |
mysublist = strchr(mysublist, '='); |
66 |
+ |
if (!mysublist++ | !reqs) |
67 |
+ |
return(0); /* not a feature list */ |
68 |
+ |
while (*reqs) { /* check each of their subfeature requests */ |
69 |
+ |
char subfeat[64]; |
70 |
+ |
char *cp = subfeat; |
71 |
+ |
int n; |
72 |
+ |
while (*reqs && (*cp = *reqs++) != ',') |
73 |
+ |
cp++; |
74 |
+ |
*cp = '\0'; |
75 |
+ |
n = cp - subfeat; |
76 |
+ |
if (!(cp = strstr(mysublist, subfeat)) || |
77 |
+ |
(cp[-1] != ',') & (cp[-1] != '=') || |
78 |
+ |
(cp[n] != ',') & (cp[n] != '\n')) |
79 |
+ |
return(0); /* missing this one! */ |
80 |
+ |
} |
81 |
+ |
return(1); /* matched them all */ |
82 |
+ |
} |
83 |
+ |
|
84 |
+ |
|
85 |
|
int |
86 |
< |
getrenderopt(ac, av) /* get next render option */ |
87 |
< |
int ac; |
88 |
< |
char *av[]; |
86 |
> |
feature_status( /* report active feature list / check specifics */ |
87 |
> |
int ac, |
88 |
> |
char *av[] |
89 |
> |
) |
90 |
|
{ |
91 |
+ |
if (ac <= 0) /* report entire list? */ |
92 |
+ |
fputs(RFeatureList, stdout); |
93 |
+ |
|
94 |
+ |
for ( ; ac-- > 0; av++) { /* check each argument */ |
95 |
+ |
char *cp; |
96 |
+ |
if (!*av[0]) continue; |
97 |
+ |
if ((cp = strchr(av[0], '=')) != NULL) { |
98 |
+ |
if (!match_subfeatures(get_feature(av[0]), cp+1)) |
99 |
+ |
goto missing_feature; |
100 |
+ |
} else if ((cp = get_feature(av[0])) != NULL) { |
101 |
+ |
char *tp = strchr(cp, '='); |
102 |
+ |
if (tp && tp < strchr(cp, '\n')) |
103 |
+ |
do |
104 |
+ |
fputc(*cp, stdout); |
105 |
+ |
while (*cp++ != '\n'); |
106 |
+ |
} else |
107 |
+ |
goto missing_feature; |
108 |
+ |
} |
109 |
+ |
return(0); /* return satisfactory status */ |
110 |
+ |
missing_feature: /* or report error */ |
111 |
+ |
fprintf(stderr, "%s: missing feature - %s\n", progname, av[0]); |
112 |
+ |
return(1); |
113 |
+ |
} |
114 |
+ |
|
115 |
+ |
|
116 |
+ |
int |
117 |
+ |
getrenderopt( /* get next render option */ |
118 |
+ |
int ac, |
119 |
+ |
char *av[] |
120 |
+ |
) |
121 |
+ |
{ |
122 |
|
#define check(ol,al) if (av[0][ol] || \ |
123 |
|
badarg(ac-1,av+1,al)) \ |
124 |
|
return(-1) |
125 |
< |
#define bool(olen,var) switch (av[0][olen]) { \ |
125 |
> |
#define check_bool(olen,var) switch (av[0][olen]) { \ |
126 |
|
case '\0': var = !var; break; \ |
127 |
|
case 'y': case 'Y': case 't': case 'T': \ |
128 |
|
case '+': case '1': var = 1; break; \ |
136 |
|
return(-1); |
137 |
|
/* check if it's one we know */ |
138 |
|
switch (av[0][1]) { |
139 |
+ |
case 'u': /* uncorrelated sampling */ |
140 |
+ |
check_bool(2,rand_samp); |
141 |
+ |
return(0); |
142 |
|
case 'b': /* back face vis. */ |
143 |
|
if (av[0][2] == 'v') { |
144 |
< |
bool(3,backvis); |
144 |
> |
check_bool(3,backvis); |
145 |
|
return(0); |
146 |
|
} |
147 |
|
break; |
168 |
|
vspretest = atoi(av[1]); |
169 |
|
return(1); |
170 |
|
case 'v': /* visibility */ |
171 |
< |
bool(3,directvis); |
171 |
> |
check_bool(3,directvis); |
172 |
|
return(0); |
173 |
|
case 's': /* size */ |
174 |
|
check(3,"f"); |
182 |
|
check(3,"f"); |
183 |
|
specthresh = atof(av[1]); |
184 |
|
return(1); |
185 |
< |
case 'j': /* jitter */ |
185 |
> |
case 's': /* sampling */ |
186 |
|
check(3,"f"); |
187 |
|
specjitter = atof(av[1]); |
188 |
|
return(1); |
201 |
|
} |
202 |
|
break; |
203 |
|
case 'i': /* irradiance */ |
204 |
< |
bool(2,do_irrad); |
204 |
> |
check_bool(2,do_irrad); |
205 |
|
return(0); |
206 |
|
case 'a': /* ambient */ |
207 |
|
switch (av[0][2]) { |
243 |
|
amblp = amblist; |
244 |
|
} |
245 |
|
if (av[0][2] == 'I') { /* file */ |
246 |
< |
rval = wordfile(amblp, |
247 |
< |
getpath(av[1],getlibpath(),R_OK)); |
246 |
> |
rval = wordfile(amblp, AMBLLEN-(amblp-amblist), |
247 |
> |
getpath(av[1],getrlibpath(),R_OK)); |
248 |
|
if (rval < 0) { |
249 |
|
sprintf(errmsg, |
250 |
< |
"cannot open ambient include file \"%s\"", av[0]); |
250 |
> |
"cannot open ambient include file \"%s\"", av[1]); |
251 |
|
error(SYSTEM, errmsg); |
252 |
|
} |
253 |
|
amblp += rval; |
254 |
|
} else { |
255 |
< |
*amblp++ = av[1]; |
255 |
> |
*amblp++ = savqstr(av[1]); |
256 |
|
*amblp = NULL; |
257 |
|
} |
258 |
|
return(1); |
264 |
|
amblp = amblist; |
265 |
|
} |
266 |
|
if (av[0][2] == 'E') { /* file */ |
267 |
< |
rval = wordfile(amblp, |
268 |
< |
getpath(av[1],getlibpath(),R_OK)); |
267 |
> |
rval = wordfile(amblp, AMBLLEN-(amblp-amblist), |
268 |
> |
getpath(av[1],getrlibpath(),R_OK)); |
269 |
|
if (rval < 0) { |
270 |
|
sprintf(errmsg, |
271 |
< |
"cannot open ambient exclude file \"%s\"", av[0]); |
271 |
> |
"cannot open ambient exclude file \"%s\"", av[1]); |
272 |
|
error(SYSTEM, errmsg); |
273 |
|
} |
274 |
|
amblp += rval; |
275 |
|
} else { |
276 |
< |
*amblp++ = av[1]; |
276 |
> |
*amblp++ = savqstr(av[1]); |
277 |
|
*amblp = NULL; |
278 |
|
} |
279 |
|
return(1); |
280 |
|
case 'f': /* file */ |
281 |
|
check(3,"s"); |
282 |
< |
ambfile= av[1]; |
282 |
> |
ambfile = savqstr(av[1]); |
283 |
|
return(1); |
284 |
|
} |
285 |
|
break; |
308 |
|
} |
309 |
|
break; |
310 |
|
} |
311 |
< |
return(-1); /* unknown option */ |
311 |
> |
|
312 |
> |
/* PMAP: Parse photon mapping options */ |
313 |
> |
return(getPmapRenderOpt(ac, av)); |
314 |
> |
|
315 |
> |
/* return(-1); */ /* unknown option */ |
316 |
|
|
317 |
|
#undef check |
318 |
< |
#undef bool |
318 |
> |
#undef check_bool |
319 |
|
} |
320 |
|
|
321 |
|
|
322 |
|
void |
323 |
< |
print_rdefaults() /* print default render values to stdout */ |
323 |
> |
print_rdefaults(void) /* print default render values to stdout */ |
324 |
|
{ |
271 |
– |
register char *cp; |
272 |
– |
|
325 |
|
printf(do_irrad ? "-i+\t\t\t\t# irradiance calculation on\n" : |
326 |
|
"-i-\t\t\t\t# irradiance calculation off\n"); |
327 |
+ |
printf(rand_samp ? "-u+\t\t\t\t# uncorrelated Monte Carlo sampling\n" : |
328 |
+ |
"-u-\t\t\t\t# correlated quasi-Monte Carlo sampling\n"); |
329 |
|
printf(backvis ? "-bv+\t\t\t\t# back face visibility on\n" : |
330 |
|
"-bv-\t\t\t\t# back face visibility off\n"); |
331 |
|
printf("-dt %f\t\t\t# direct threshold\n", shadthresh); |
336 |
|
printf("-dp %-9d\t\t\t# direct pretest density\n", vspretest); |
337 |
|
printf(directvis ? "-dv+\t\t\t\t# direct visibility on\n" : |
338 |
|
"-dv-\t\t\t\t# direct visibility off\n"); |
339 |
< |
printf("-sj %f\t\t\t# specular jitter\n", specjitter); |
339 |
> |
printf("-ss %f\t\t\t# specular sampling\n", specjitter); |
340 |
|
printf("-st %f\t\t\t# specular threshold\n", specthresh); |
341 |
|
printf("-av %f %f %f\t# ambient value\n", colval(ambval,RED), |
342 |
|
colval(ambval,GRN), colval(ambval, BLU)); |
354 |
|
colval(salbedo,GRN), colval(salbedo,BLU)); |
355 |
|
printf("-mg %f\t\t\t# mist scattering eccentricity\n", seccg); |
356 |
|
printf("-ms %f\t\t\t# mist sampling distance\n", ssampdist); |
357 |
< |
printf("-lr %-9d\t\t\t# limit reflection\n", maxdepth); |
358 |
< |
printf("-lw %f\t\t\t# limit weight\n", minweight); |
357 |
> |
printf("-lr %-9d\t\t\t# limit reflection%s\n", maxdepth, |
358 |
> |
maxdepth<=0 ? " (Russian roulette)" : ""); |
359 |
> |
printf("-lw %.2e\t\t\t# limit weight\n", minweight); |
360 |
> |
|
361 |
> |
/* PMAP: output photon map defaults */ |
362 |
> |
printPmapDefaults(); |
363 |
|
} |