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