1 |
greg |
2.6 |
#ifndef lint |
2 |
rschregle |
2.9 |
static const char RCSid[] = "$Id: pmapopt.c,v 2.8 2016/05/17 17:39:47 rschregle Exp $"; |
3 |
greg |
2.6 |
#endif |
4 |
rschregle |
2.8 |
|
5 |
greg |
2.1 |
/* |
6 |
|
|
================================================================== |
7 |
|
|
Photon map interface to RADIANCE render options |
8 |
|
|
|
9 |
|
|
Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) |
10 |
|
|
(c) Fraunhofer Institute for Solar Energy Systems, |
11 |
rschregle |
2.2 |
(c) Lucerne University of Applied Sciences and Arts, |
12 |
|
|
supported by the Swiss National Science Foundation (SNSF, #147053) |
13 |
greg |
2.1 |
================================================================== |
14 |
|
|
|
15 |
rschregle |
2.9 |
$Id: pmapopt.c,v 2.8 2016/05/17 17:39:47 rschregle Exp $ |
16 |
greg |
2.1 |
*/ |
17 |
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
greg |
2.3 |
#include "ray.h" |
21 |
greg |
2.1 |
#include "pmapparm.h" |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
|
25 |
|
|
int getPmapRenderOpt (int ac, char *av []) |
26 |
|
|
/* Parse next render option for photon map; interface to getrenderopt(); |
27 |
|
|
* return -1 if parsing failed, else number of parameters consumed */ |
28 |
|
|
{ |
29 |
|
|
#define check(ol,al) (av[0][ol] || badarg(ac-1,av+1,al)) |
30 |
|
|
|
31 |
|
|
static int t = -1; /* pmap parameter index */ |
32 |
|
|
|
33 |
|
|
if (ac < 1 || !av [0] || av [0][0] != '-') |
34 |
|
|
return -1; |
35 |
|
|
|
36 |
|
|
switch (av [0][1]) { |
37 |
|
|
case 'a': |
38 |
|
|
switch (av [0][2]) { |
39 |
|
|
case 'p': /* photon map */ |
40 |
rschregle |
2.8 |
/* Asking for photon map, ergo ambounce != 0 */ |
41 |
|
|
ambounce += (ambounce == 0); |
42 |
|
|
|
43 |
greg |
2.1 |
if (!check(3, "s")) { |
44 |
|
|
/* File -> assume bwidth = 1 or precomputed pmap */ |
45 |
|
|
if (++t >= NUM_PMAP_TYPES) |
46 |
|
|
error(USER, "too many photon maps"); |
47 |
|
|
|
48 |
|
|
pmapParams [t].fileName = savqstr(av [1]); |
49 |
|
|
pmapParams [t].minGather = pmapParams [t].maxGather = |
50 |
|
|
defaultGather; |
51 |
|
|
} |
52 |
|
|
else return -1; |
53 |
|
|
|
54 |
|
|
if (!check(3, "si")) { |
55 |
|
|
/* File + bandwidth */ |
56 |
|
|
pmapParams [t].minGather = pmapParams [t].maxGather = |
57 |
|
|
atoi(av [2]); |
58 |
|
|
|
59 |
|
|
if (!pmapParams [t].minGather) |
60 |
|
|
return -1; |
61 |
|
|
} |
62 |
|
|
else { |
63 |
rschregle |
2.9 |
sprintf(errmsg, "missing photon lookup bandwidth, " |
64 |
|
|
"defaulting to %d", defaultGather); |
65 |
greg |
2.1 |
error(WARNING, errmsg); |
66 |
|
|
return 1; |
67 |
|
|
} |
68 |
|
|
|
69 |
|
|
if (!check(3, "sii")) { |
70 |
|
|
/* File + min bwidth + max bwidth -> bias compensation */ |
71 |
|
|
pmapParams [t].maxGather = atoi(av [3]); |
72 |
|
|
|
73 |
|
|
if (pmapParams [t].minGather >= pmapParams [t].maxGather) |
74 |
|
|
return -1; |
75 |
|
|
|
76 |
|
|
return 3; |
77 |
|
|
} |
78 |
|
|
else return 2; |
79 |
|
|
|
80 |
rschregle |
2.5 |
case 'm': /* Fixed max photon search radius */ |
81 |
|
|
if (check(3, "f") || (maxDistFix = atof(av [1])) <= 0) |
82 |
greg |
2.1 |
error(USER, "invalid max photon search radius coefficient"); |
83 |
|
|
|
84 |
|
|
return 1; |
85 |
rschregle |
2.8 |
|
86 |
|
|
#ifdef PMAP_OOC |
87 |
|
|
case 'c': /* OOC pmap cache page size ratio */ |
88 |
|
|
if (check(3, "f") || (pmapCachePageSize = atof(av [1])) <= 0) |
89 |
|
|
error(USER, "invalid photon cache page size ratio"); |
90 |
|
|
|
91 |
|
|
return 1; |
92 |
|
|
|
93 |
|
|
case 'C': /* OOC pmap cache size (in photons); 0 = no caching */ |
94 |
|
|
if (check(3, "s")) |
95 |
|
|
error(USER, "invalid number of cached photons"); |
96 |
|
|
|
97 |
|
|
/* Parsing failure sets to zero and disables caching */ |
98 |
|
|
pmapCacheSize = parseMultiplier(av [1]); |
99 |
|
|
|
100 |
|
|
return 1; |
101 |
|
|
#endif |
102 |
greg |
2.1 |
} |
103 |
|
|
} |
104 |
|
|
#undef check |
105 |
|
|
|
106 |
|
|
/* Unknown option */ |
107 |
|
|
return -1; |
108 |
|
|
} |
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
void printPmapDefaults () |
113 |
|
|
/* Print defaults for photon map render options */ |
114 |
|
|
{ |
115 |
rschregle |
2.5 |
printf("-am %.1f\t\t\t\t# max photon search radius\n", maxDistFix); |
116 |
rschregle |
2.8 |
#ifdef PMAP_OOC |
117 |
|
|
printf("-ac %.1f\t\t\t\t# photon cache page size ratio\n", |
118 |
|
|
pmapCachePageSize); |
119 |
|
|
printf("-aC %ld\t\t\t# num cached photons\n", pmapCacheSize); |
120 |
|
|
#endif |
121 |
greg |
2.1 |
} |