1 |
greg |
2.1 |
/* |
2 |
|
|
================================================================== |
3 |
|
|
Photon map main header |
4 |
|
|
|
5 |
|
|
Roland Schregle (roland.schregle@{hslu.ch, gmail.com}) |
6 |
|
|
(c) Fraunhofer Institute for Solar Energy Systems, |
7 |
rschregle |
2.3 |
(c) Lucerne University of Applied Sciences and Arts, |
8 |
|
|
supported by the Swiss National Science Foundation (SNSF, #147053) |
9 |
greg |
2.1 |
================================================================== |
10 |
|
|
|
11 |
rschregle |
2.3 |
$Id: pmap.h,v 2.2 2015/04/21 19:16:51 greg Exp $ |
12 |
greg |
2.1 |
*/ |
13 |
|
|
|
14 |
|
|
|
15 |
|
|
#ifndef PMAP_H |
16 |
|
|
#define PMAP_H |
17 |
|
|
|
18 |
|
|
#include "pmapparm.h" |
19 |
|
|
#include "pmapdata.h" |
20 |
|
|
|
21 |
|
|
|
22 |
greg |
2.2 |
#ifndef min |
23 |
|
|
#define min(a, b) ((a) < (b) ? (a) : (b)) |
24 |
|
|
#endif |
25 |
|
|
|
26 |
|
|
#ifndef max |
27 |
|
|
#define max(a, b) ((a) > (b) ? (a) : (b)) |
28 |
|
|
#endif |
29 |
|
|
|
30 |
greg |
2.1 |
#define sqr(a) ((a) * (a)) |
31 |
|
|
|
32 |
|
|
/* Average over colour channels */ |
33 |
|
|
#define colorAvg(col) ((col [0] + col [1] + col [2]) / 3) |
34 |
|
|
|
35 |
|
|
/* Macros to test for enabled photon maps */ |
36 |
|
|
#define photonMapping (globalPmap || preCompPmap || \ |
37 |
|
|
causticPmap ||contribPmap) |
38 |
|
|
#define causticPhotonMapping (causticPmap) |
39 |
|
|
#define directPhotonMapping (directPmap) |
40 |
|
|
#define volumePhotonMapping (volumePmap) |
41 |
|
|
#define contribPhotonMapping (contribPmap && contribPmap -> srcContrib) |
42 |
|
|
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
extern void (*pmapLookup [])(PhotonMap*, RAY*, COLOR); |
46 |
|
|
/* Photon map lookup functions per type */ |
47 |
|
|
|
48 |
|
|
void loadPmaps (PhotonMap **pmaps, const PhotonMapParams *params); |
49 |
|
|
/* Load photon and set their respective parameters, checking timestamps |
50 |
|
|
* relative to octree for possible staleness */ |
51 |
|
|
|
52 |
|
|
void savePmaps (const PhotonMap **pmaps, int argc, char **argv); |
53 |
|
|
/* Save all defined photon maps with specified command line */ |
54 |
|
|
|
55 |
|
|
void cleanUpPmaps (PhotonMap **pmaps); |
56 |
|
|
/* Trash all photon maps after processing is complete */ |
57 |
|
|
|
58 |
|
|
void distribPhotons (PhotonMap **pmaps); |
59 |
|
|
/* Emit photons from light sources and build photon maps for non-NULL |
60 |
|
|
* entries in photon map array */ |
61 |
|
|
|
62 |
|
|
void tracePhoton (RAY*); |
63 |
|
|
/* Follow photon as it bounces around the scene. Analogon to |
64 |
|
|
* raytrace(). */ |
65 |
|
|
|
66 |
|
|
void photonDensity (PhotonMap*, RAY*, COLOR irrad); |
67 |
|
|
/* Perform surface density estimate from incoming photon flux at |
68 |
|
|
ray's intersection point. Returns irradiance from found photons. */ |
69 |
|
|
|
70 |
|
|
void photonPreCompDensity (PhotonMap *pmap, RAY *r, COLOR irrad); |
71 |
|
|
/* Returns precomputed photon density estimate at ray -> rop. */ |
72 |
|
|
|
73 |
|
|
void volumePhotonDensity (PhotonMap*, RAY*, COLOR); |
74 |
|
|
/* Perform volume density estimate from incoming photon flux at |
75 |
|
|
ray's intersection point. Returns irradiance. */ |
76 |
|
|
|
77 |
|
|
void colorNorm (COLOR); |
78 |
|
|
/* Normalise colour channels to average of 1 */ |
79 |
|
|
|
80 |
|
|
#endif |