ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapparm.c
Revision: 2.8
Committed: Mon Aug 14 21:12:10 2017 UTC (6 years, 9 months ago) by rschregle
Content type: text/plain
Branch: MAIN
CVS Tags: rad5R1
Changes since 2.7: +6 -7 lines
Log Message:
Updated photon map code for Windows; no multproc or ooC for now

File Contents

# User Rev Content
1 greg 2.5 #ifndef lint
2 rschregle 2.8 static const char RCSid[] = "$Id: pmapparm.c,v 2.7 2016/05/17 17:39:47 rschregle Exp $";
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.8 $Id: pmapparm.c,v 2.7 2016/05/17 17:39:47 rschregle Exp $
17 greg 2.1 */
18    
19    
20     #include "pmapparm.h"
21     #include "pmapdata.h"
22     #include <ctype.h>
23    
24    
25 rschregle 2.7 float pdfSamples = 1000, /* PDF samples per steradian */
26    
27     finalGather = 0.25, /* fraction of global photons for
28     irradiance precomputation */
29    
30     preDistrib = 0.25, /* fraction of num photons for
31     distribution prepass */
32    
33     gatherTolerance = 0.5, /* Photon map lookup tolerance;
34     lookups returning fewer than this
35     fraction of minGather/maxGather
36     are restarted with a larger
37     search radius */
38    
39     maxDistFix = 0; /* Static maximum photon search
40     radius (radius is adaptive if
41     this is zero) */
42    
43     #ifdef PMAP_OOC
44     float pmapCachePageSize = 8; /* OOC cache pagesize as multiple
45     * of maxGather */
46     unsigned long pmapCacheSize = 1e6; /* OOC cache size in photons */
47     #endif
48    
49 greg 2.1
50 rschregle 2.8 /* Regions of interest */
51     unsigned pmapNumROI = 0;
52     PhotonMapROI *pmapROI = NULL;
53 greg 2.1
54 rschregle 2.7
55 rschregle 2.8 unsigned verbose = 0; /* Verbose console output */
56 rschregle 2.7 unsigned long photonMaxBounce = 5000; /* Runaway photon bounce limit */
57     unsigned photonRepTime = 0, /* Seconds between reports */
58     maxPreDistrib = 4, /* Max predistrib passes */
59     defaultGather = 40; /* Default num photons for lookup */
60    
61 greg 2.1
62     /* Per photon map params */
63     PhotonMapParams pmapParams [NUM_PMAP_TYPES] = {
64     {NULL, 0, 0, 0}, {NULL, 0, 0, 0}, {NULL, 0, 0, 0}, {NULL, 0, 0, 0},
65     {NULL, 0, 0, 0}, {NULL, 0, 0, 0}
66     };
67    
68    
69     int setPmapParam (PhotonMap** pm, const PhotonMapParams* parm)
70     {
71     if (parm && parm -> fileName) {
72     if (!(*pm = (PhotonMap*)malloc(sizeof(PhotonMap))))
73     error(INTERNAL, "failed to allocate photon map");
74    
75     (*pm) -> fileName = parm -> fileName;
76     (*pm) -> minGather = parm -> minGather;
77     (*pm) -> maxGather = parm -> maxGather;
78     (*pm) -> distribTarget = parm -> distribTarget;
79     (*pm) -> maxDist0 = FHUGE;
80     (*pm) -> srcContrib = NULL;
81    
82     return 1;
83     }
84    
85     return 0;
86     }
87    
88    
89     unsigned long parseMultiplier (const char *num)
90     {
91     unsigned long mult = 1;
92     const int strEnd = strlen(num) - 1;
93    
94     if (strEnd <= 0)
95     return 0;
96    
97     if (!isdigit(num [strEnd]))
98     switch (toupper(num [strEnd])) {
99     case 'G': mult *= 1000;
100     case 'M': mult *= 1000;
101     case 'K': mult *= 1000;
102     break;
103     default : error(USER, "unknown multiplier");
104     }
105    
106     return (unsigned long)(mult * atof(num));
107     }