-
Notifications
You must be signed in to change notification settings - Fork 1
/
photon_mapping.h
65 lines (52 loc) · 1.52 KB
/
photon_mapping.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef _PHOTON_MAPPING_H_
#define _PHOTON_MAPPING_H_
#include <vector>
#include "vectors.h"
#include "photon.h"
class Mesh;
class ArgParser;
class KDTree;
class Ray;
class Hit;
class RayTracer;
class Radiosity;
class Sphere;
// =========================================================================
// The basic class to shoot photons within the scene and collect and
// process the nearest photons for use in the raytracer
extern Vec3f global_energy;
class PhotonMapping {
public:
// CONSTRUCTOR & DESTRUCTOR
PhotonMapping(Mesh *_mesh, ArgParser *_args) {
mesh = _mesh;
args = _args;
raytracer = NULL;
kdtree = NULL;
}
~PhotonMapping();
void setRayTracer(RayTracer *r) { raytracer = r; }
void setRadiosity(Radiosity *r) { radiosity = r; }
// step 1: send the photons throughout the scene
void TracePhotons();
// step 2: collect the photons and return the contribution from indirect illumination
Vec3f GatherIndirect(const Vec3f &point, const Vec3f &normal, const Vec3f &direction_from) const;
Vec3f CalculateEnergy(Sphere* s);
// for visualization
void RenderPhotons();
void RenderKDTree();
void RenderEnergy();
private:
// trace a single photon
void TracePhoton(const Vec3f &position, const Vec3f &direction, const Vec3f &energy, int iter) const;
// helper functions for visualization
void RenderPhotonPositions();
void RenderPhotonDirections();
// REPRESENTATION
KDTree *kdtree;
Mesh *mesh;
ArgParser *args;
RayTracer *raytracer;
Radiosity *radiosity;
};
#endif