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