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