ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapparm.c
Revision: 2.7
Committed: Tue May 17 17:39:47 2016 UTC (8 years, 11 months ago) by rschregle
Content type: text/plain
Branch: MAIN
Changes since 2.6: +40 -28 lines
Log Message:
Initial import of ooC photon map

File Contents

# User Rev Content
1 greg 2.5 #ifndef lint
2 rschregle 2.7 static const char RCSid[] = "$Id: pmapparm.c,v 1.12 2016/02/12 12:51:12 taschreg Exp taschreg $";
3 greg 2.5 #endif
4 rschregle 2.7
5 greg 2.1 /*
6 rschregle 2.7 ======================================================================
7     Parameters for photon map generation and rendering; used by mkpmap
8     and rpict/rvu/rtrace.
9 greg 2.1
10     Roland Schregle (roland.schregle@{hslu.ch, gmail.com}
11     (c) Fraunhofer Institute for Solar Energy Systems,
12 rschregle 2.2 (c) Lucerne University of Applied Sciences and Arts,
13 rschregle 2.7 supported by the Swiss National Science Foundation (SNSF, #147053)
14     ======================================================================
15 greg 2.1
16 rschregle 2.7 $Id: pmapparm.c,v 1.12 2016/02/12 12:51:12 taschreg Exp taschreg $
17 greg 2.1 */
18    
19    
20     #include "pmapparm.h"
21     #include "pmapdata.h"
22     #include "standard.h"
23     #include <ctype.h>
24    
25    
26 rschregle 2.7 float pdfSamples = 1000, /* PDF samples per steradian */
27    
28     finalGather = 0.25, /* fraction of global photons for
29     irradiance precomputation */
30    
31     preDistrib = 0.25, /* fraction of num photons for
32     distribution prepass */
33    
34     gatherTolerance = 0.5, /* Photon map lookup tolerance;
35     lookups returning fewer than this
36     fraction of minGather/maxGather
37     are restarted with a larger
38     search radius */
39    
40     maxDistFix = 0; /* Static maximum photon search
41     radius (radius is adaptive if
42     this is zero) */
43    
44     #ifdef PMAP_OOC
45     float pmapCachePageSize = 8; /* OOC cache pagesize as multiple
46     * of maxGather */
47     unsigned long pmapCacheSize = 1e6; /* OOC cache size in photons */
48     #endif
49    
50 greg 2.1
51     #ifdef PMAP_ROI
52 rschregle 2.7 /* Region of interest bbox: {xmin, xmax, ymin, ymax, zmin, zmax} */
53     float pmapROI [6] = {-FHUGE, FHUGE, -FHUGE, FHUGE, -FHUGE, FHUGE};
54 greg 2.1 #endif
55    
56 rschregle 2.7
57     unsigned long photonMaxBounce = 5000; /* Runaway photon bounce limit */
58     unsigned photonRepTime = 0, /* Seconds between reports */
59     maxPreDistrib = 4, /* Max predistrib passes */
60     defaultGather = 40; /* Default num photons for lookup */
61    
62 greg 2.1
63     /* Per photon map params */
64     PhotonMapParams pmapParams [NUM_PMAP_TYPES] = {
65     {NULL, 0, 0, 0}, {NULL, 0, 0, 0}, {NULL, 0, 0, 0}, {NULL, 0, 0, 0},
66     {NULL, 0, 0, 0}, {NULL, 0, 0, 0}
67     };
68    
69    
70     int setPmapParam (PhotonMap** pm, const PhotonMapParams* parm)
71     {
72     if (parm && parm -> fileName) {
73     if (!(*pm = (PhotonMap*)malloc(sizeof(PhotonMap))))
74     error(INTERNAL, "failed to allocate photon map");
75    
76     (*pm) -> fileName = parm -> fileName;
77     (*pm) -> minGather = parm -> minGather;
78     (*pm) -> maxGather = parm -> maxGather;
79     (*pm) -> distribTarget = parm -> distribTarget;
80     (*pm) -> maxDist0 = FHUGE;
81     (*pm) -> srcContrib = NULL;
82    
83     return 1;
84     }
85    
86     return 0;
87     }
88    
89    
90     unsigned long parseMultiplier (const char *num)
91     {
92     unsigned long mult = 1;
93     const int strEnd = strlen(num) - 1;
94    
95     if (strEnd <= 0)
96     return 0;
97    
98     if (!isdigit(num [strEnd]))
99     switch (toupper(num [strEnd])) {
100     case 'G': mult *= 1000;
101     case 'M': mult *= 1000;
102     case 'K': mult *= 1000;
103     break;
104     default : error(USER, "unknown multiplier");
105     }
106    
107     return (unsigned long)(mult * atof(num));
108     }