1 |
/* |
2 |
================================================================== |
3 |
Photon map support routines for emission from light sources |
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: pmapsrc.h,v 1.5 2014/12/03 15:06:10 taschreg Exp taschreg $ |
11 |
*/ |
12 |
|
13 |
|
14 |
|
15 |
#ifndef PMAPSRC_H |
16 |
#define PMAPSRC_H |
17 |
|
18 |
#include "ray.h" |
19 |
#include "source.h" |
20 |
|
21 |
|
22 |
|
23 |
/* Data structures for photon emission */ |
24 |
typedef struct { |
25 |
unsigned theta, phi; /* Direction indices */ |
26 |
COLOR pdf; /* Probability of emission in this |
27 |
direction per RGB */ |
28 |
float cdf; /* Cumulative probability up to |
29 |
this sample */ |
30 |
} EmissionSample; |
31 |
|
32 |
typedef struct { |
33 |
unsigned numTheta, numPhi; /* Num divisions in theta & phi */ |
34 |
RREAL cosThetaMax; /* cos(source aperture) */ |
35 |
FVECT uh, vh, wh; /* Emission aperture axes at origin, |
36 |
w is normal*/ |
37 |
FVECT us, vs, ws; /* Source surface axes at origin, |
38 |
w is normal */ |
39 |
FVECT photonOrg; /* Current photon origin */ |
40 |
EmissionSample *samples; /* PDF samples for photon emission |
41 |
directions */ |
42 |
unsigned long numPartitions; /* Number of surface partitions */ |
43 |
RREAL partArea; /* Area covered by each partition */ |
44 |
SRCREC *src, *port; /* Current source and port */ |
45 |
unsigned long partitionCnt, /* Current surface partition */ |
46 |
maxPartitions, /* Max allocated partitions */ |
47 |
numSamples; /* Number of PDF samples */ |
48 |
unsigned char* partitions; /* Source surface partitions */ |
49 |
COLOR partFlux; /* Total flux emitted by partition */ |
50 |
float cdf; /* Cumulative probability */ |
51 |
} EmissionMap; |
52 |
|
53 |
|
54 |
|
55 |
/* Photon port list for emission from geometry en lieu of light sources */ |
56 |
extern SRCREC *photonPorts; |
57 |
extern unsigned numPhotonPorts; |
58 |
|
59 |
/* Dispatch tables for partitioning light source surfaces and generating |
60 |
an origin for photon emission */ |
61 |
extern void (*photonPartition []) (EmissionMap*); |
62 |
extern void (*photonOrigin []) (EmissionMap*); |
63 |
|
64 |
|
65 |
|
66 |
void getPhotonPorts (); |
67 |
/* Find geometry declared as photon ports */ |
68 |
|
69 |
void initPhotonEmissionFuncs (); |
70 |
/* Init photonPartition[] and photonOrigin[] dispatch tables with source |
71 |
specific emission routines */ |
72 |
|
73 |
void initPhotonEmission (EmissionMap *emap, float numPdfSamples); |
74 |
/* Initialize photon emission from partitioned light source emap -> src; |
75 |
* this involves integrating the flux emitted from the current photon |
76 |
* origin emap -> photonOrg and setting up a PDF to sample the emission |
77 |
* distribution with numPdfSamples samples */ |
78 |
|
79 |
void emitPhoton (const EmissionMap*, RAY* ray); |
80 |
/* Emit photon from current source partition based on emission |
81 |
distribution and return new photon ray */ |
82 |
|
83 |
void multDirectPmap (RAY *r); |
84 |
/* Factor irradiance from direct photons into r -> rcol; interface to |
85 |
* direct() */ |
86 |
|
87 |
void inscatterVolumePmap (RAY *r, COLOR inscatter); |
88 |
/* Add inscattering from volume photon map; interface to srcscatter() */ |
89 |
|
90 |
#endif |