ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/pmapparm.c
Revision: 2.1
Committed: Tue Feb 24 19:39:27 2015 UTC (9 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial check-in of photon map addition by Roland Schregle

File Contents

# Content
1 /*
2 ==================================================================
3 Parameters common to all photon map modules.
4
5 Roland Schregle (roland.schregle@{hslu.ch, gmail.com}
6 (c) Fraunhofer Institute for Solar Energy Systems,
7 Lucerne University of Applied Sciences & Arts
8 ==================================================================
9
10 $Id: pmapparm.c,v 1.10 2015/01/29 13:13:08 taschreg Exp taschreg $
11 */
12
13
14 #include "pmapparm.h"
15 #include "pmapdata.h"
16 #include "standard.h"
17 #include <ctype.h>
18
19
20 float pdfSamples = 1000, /* PDF samples per steradian */
21 finalGather = 0.25, /* fraction of global photons for
22 irradiance precomputation */
23 preDistrib = 0.25, /* fraction of num photons for
24 distribution prepass */
25 gatherTolerance = 0.5, /* Photon map lookup tolerance;
26 lookups returning fewer than this
27 fraction of minGather/maxGather
28 are restarted with a larger
29 search radius */
30 maxDistCoeff = 100; /* Coefficient for maximum photon
31 search radius */
32
33 #ifdef PMAP_ROI
34 /* Region of interest bbox: {xmin, xmax, ymin, ymax, zmin, zmax} */
35 float pmapROI [6] = {-FHUGE, FHUGE, -FHUGE, FHUGE, -FHUGE, FHUGE};
36 #endif
37
38 unsigned long photonHeapSizeInc = 1000, /* Photon heap size increment */
39 photonMaxBounce = 5000; /* Runaway photon bounce limit */
40
41 unsigned photonRepTime = 0, /* Seconds between reports */
42 maxPreDistrib = 4, /* Max predistrib passes */
43 defaultGather = 40; /* Default num photons for lookup */
44
45 /* Per photon map params */
46 PhotonMapParams pmapParams [NUM_PMAP_TYPES] = {
47 {NULL, 0, 0, 0}, {NULL, 0, 0, 0}, {NULL, 0, 0, 0}, {NULL, 0, 0, 0},
48 {NULL, 0, 0, 0}, {NULL, 0, 0, 0}
49 };
50
51
52 int setPmapParam (PhotonMap** pm, const PhotonMapParams* parm)
53 {
54 if (parm && parm -> fileName) {
55 if (!(*pm = (PhotonMap*)malloc(sizeof(PhotonMap))))
56 error(INTERNAL, "failed to allocate photon map");
57
58 (*pm) -> fileName = parm -> fileName;
59 (*pm) -> minGather = parm -> minGather;
60 (*pm) -> maxGather = parm -> maxGather;
61 (*pm) -> distribTarget = parm -> distribTarget;
62 (*pm) -> heapSizeInc = photonHeapSizeInc;
63 (*pm) -> maxDist0 = FHUGE;
64 (*pm) -> srcContrib = NULL;
65
66 return 1;
67 }
68
69 return 0;
70 }
71
72
73 unsigned long parseMultiplier (const char *num)
74 {
75 unsigned long mult = 1;
76 const int strEnd = strlen(num) - 1;
77
78 if (strEnd <= 0)
79 return 0;
80
81 if (!isdigit(num [strEnd]))
82 switch (toupper(num [strEnd])) {
83 case 'G': mult *= 1000;
84 case 'M': mult *= 1000;
85 case 'K': mult *= 1000;
86 break;
87 default : error(USER, "unknown multiplier");
88 }
89
90 return (unsigned long)(mult * atof(num));
91 }